Python & FastAPI - Annotated Type for Data Validation + Metadata!

preview_player
Показать описание
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:

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
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:

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:

#python #fastapi #webdevelopment
Рекомендации по теме
Комментарии
Автор

I watched your complete fastai playlist over this weekend. It was very very helpful. Thank you for making these !

ShivamKushwaha-ol
Автор

очень круто, бро! читаю документацию и параллельно смотрю твои видео. спасибо большое!!)

ДимаПолушкин-шб
Автор

Great explanation for annotated types. A lot of other FastAPI tutorials just breeze past by these without going over them.

mattmarshall
Автор

In the final version on line 7 should it be "get_type_hints( func , include_extras =True") intead of "get_type_hints( double , include_extras =True)"

pocsgeza
Автор

Thank you very much, very clear explanation!

ivankudryavcev
Автор

Thank you for the excellent explanation, but can you give me some examples how to make a class work with square brackets like Annotated[T, x, …]

DH
Автор

I like your vids, thx for the content. You helped me with htmx!

NeoMekhar