In this video, we'll explore the Annotated type in Python, and how it can be used to add metadata to an existing type.
Custom logic can then process that metadata and perform actions based on the values used!
We'll see how Annotated is used in FastAPI with the Query, Path, Header and Cookie parameters to handler functions, and will dive deeper into the internals of the typing module to see how we can extract and process the metadata passed to Annotated.
☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:
https://ko-fi.com/bugbytes
📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
00:59 typing.Annotated - Annotated type in python
04:41 FastAPI annotations with Query and Path object
12:35 Typing module internals
19:07 Creating Decorator for annotation checks
▶️ Full Playlist:
𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📖 Blog: https://bugbytes.io/posts/
👾 Github: https://github.com/bugbytes-io/
🐦 Twitter: / bugbytesio
📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
Python Typing: https://docs.python.org/3/library/typ...
Annotated: https://docs.python.org/3/library/typ...
FastAPI Query Parameter Annotations: https://fastapi.tiangolo.com/tutorial...
StackOverflow answer: https://stackoverflow.com/questions/6...
#python #fastapi #webdevelopment
On this page of the site you can watch the video online Python & FastAPI - Annotated Type for Data Validation + Metadata! with a duration of hours minute second in good quality, which was uploaded by the user BugBytes 31 January 2024, share the link with friends and acquaintances, this video has already been watched 7,315 times on youtube and it was liked by 291 viewers. Enjoy your viewing!