What the PEP proposes
Return types could be inferred from a function’s input parameter types. [1]
Another use-case PEP 827 serves is generating new types programmatically, such as for CRUD (Create, Read, Update, Delete) web applications, where a single database table typically has a separate ORM model definition for each CRUD operation. [2]
Comprehension types can have conditional if clauses, just like regular comprehensions. [3]
Why storage matters at runtime
Popular libraries like Pydantic and FastAPI use type annotations at runtime to drive their behavior. “This was complicated by our desire to use Python-y syntax”, like if, for, and dot notation. [4]
In concrete terms, Python will itself evaluate the types at runtime. [5]
In order to implement everything in PEP 827, there would need to be a way to access the unevaluated type even after Python had [6]
The options the write-up describes
As currently drafted, “the PEP is carefully designed to support an evaluator that works by calling the __annotate__() functions”. [7]
One of the original ideas considered by the PEP that moved to __annotate__() functions was “can we just store the strings?” The most straightforward option would be for __annotate__() to support STRING in addition to VALUE and VALUE_WITH_FAKE_GLOBALS. [8]
The __annotate__() function would get a little bigger, but if STRING is passed as the format, it would return the strings “instead of requiring the library to do something complicated to get there”. [9]
Sources
- The Python Software Foundation source says: Return types could be inferred from a function’s input parameter types. PEP 827: Type Manipulation (Python Language Summit 2026)
- The Python Software Foundation source says: Another use-case PEP 827 serves is generating new types programmatically, such as for CRUD (Create, Read, Update, Delete) web applications, where a single database table typically has a separate ORM model definition for each CRUD operation. PEP 827: Type Manipulation (Python Language Summit 2026)
- The Python Software Foundation source says: Comprehension types can have conditional if clauses, just like regular comprehensions. PEP 827: Type Manipulation (Python Language Summit 2026)
- The Python Software Foundation source says: Popular libraries like Pydantic and FastAPI use type annotations at runtime to drive their behavior. “This was complicated by our desire to use Python-y syntax”, like if, for, and dot notation. PEP 827: Type Manipulation (Python Language Summit 2026)
- The Python Software Foundation source says: In concrete terms, Python will itself evaluate the types at runtime. PEP 827: Type Manipulation (Python Language Summit 2026)
- The Python Software Foundation source says: In order to implement everything in PEP 827, there would need to be a way to access the unevaluated type even after Python had PEP 827: Type Manipulation (Python Language Summit 2026)
- The Python Software Foundation source says: As currently drafted, “the PEP is carefully designed to support an evaluator that works by calling the __annotate__() functions”. PEP 827: Type Manipulation (Python Language Summit 2026)
- The Python Software Foundation source says: One of the original ideas considered by the PEP that moved to __annotate__() functions was “can we just store the strings?” The most straightforward option would be for __annotate__() to support STRING in addition to VALUE and VALUE_WITH_FAKE_GLOBALS. PEP 827: Type Manipulation (Python Language Summit 2026)
- The Python Software Foundation source says: The __annotate__() function would get a little bigger, but if STRING is passed as the format, it would return the strings “instead of requiring the library to do something complicated to get there”. PEP 827: Type Manipulation (Python Language Summit 2026)