Re:The different uses of Python type hints
by FreakLegion on Saturday April 15, 2023 @05:27PM
(#35584701)
The Annotated type is worth mentioning as well. Today in something like SQLModel you do (from the readme):
And that's fine. I wouldn't necessarily change anything here. Annotated gives you the option of approaching things in a different way, though.
I have some use cases where the alternative approach is useful, like quantification of class fields or function arguments.
[ Parent
| on HN ]
FastApi very recently added support for Annotated, and now recommends using that over default arguments.