MENU

Fun & Interesting

What IS typing.Annotated?

Carberra 8,225 lượt xem 4 months ago
Video Not Working? Fix It Now

Annotated is one of things you see around quite a bit, and while it's part of the typing library, it provides some actual runtime functionality as well! It can be used to do some pretty powerful things, so in this video, as well as learning how to use it, we'll be looking at how it's been used in the real world to do some pretty crazy things!

0:00 - Intro
0:41 - Using Annotated for attribute validation [1-4]
6:52 - Real-world case study: Msgspec [5-6]
7:58 - Real-world case study: FastAPI [7-8]
8:38 - Real-world case study: Strawberry [9]
9:30 - Outro

[1] https://docs.python.org/3/library/typing.html#typing.Annotated
[2] https://youtu.be/2hWR06BVSg8
[3] https://youtu.be/l0T4jvuP0H8
[4] https://docs.python.org/3/library/inspect.html#inspect.get_annotations
[5] https://jcristharif.com/msgspec/constraints.html
[6] https://youtu.be/vRrndjIr7Ag
[7] https://fastapi.tiangolo.com/tutorial/dependencies/
[8] https://youtu.be/ICnKq9fgLrI
[9] https://strawberry.rocks/docs/types/lazy



If you want to see more of me, join my Discord server!
https://discord.gg/5vVgQpK

I get a lot of people asking, so here's my setup!
• Visual Studio Code: https://youtu.be/PBQspYkkksU
• Terminal: https://youtu.be/4RuGK3w6Mbs
• Desk/recording gear: https://kit.co/Carberra
• PC build: https://uk.pcpartpicker.com/list/TmzGYN

Affiliations (I may earn a commission):
• Codecrafters -- 40% off any plan: https://app.codecrafters.io/join?via=parafoxia
• Keeper Password Manager -- 30% off your first year: https://keeper.io/r/EX4FB1C



If you have any questions, don't hesitate to ask in the comments! I'll try and answer as soon as I can, providing someone else hasn't already done so.

#python #coding #howto

Comment