News for hackers. Stuff that matters.
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):

    class Hero(SQLModel, table=True):
        id: Optional[int] = Field(default=None, primary_key=True)
And that's fine. I wouldn't necessarily change anything here. Annotated gives you the option of approaching things in a different way, though.

    class Hero(SQLModel, table=True):
        id: PrimaryKey[Optional[int]]
I have some use cases where the alternative approach is useful, like quantification of class fields or function arguments.
Re:The different uses of Python type hints by eirki on Sunday April 16, 2023 @05:20AM (#35588463)
FastApi very recently added support for Annotated, and now recommends using that over default arguments.

https://fastapi.tiangolo.com/release-notes/#0950