Proposed spec changes for Annotated

I am proposing a change in the specification around Annotated:

This change is not intended to change any existing behavior, only to improve terminology and clarify some underspecified aspects.

In particular, the spec change makes it explicit that Annotated may be used around any annotation expression; for example, x: Annotated[Final[int], "some metadata"] is legal, and a type checker should treat it as equivalent to x: Final[int].

The terminology proposed is for the elements within an Annotated expression. In Annotated[T, M1, M2, ...], T is the base expression of the Annotated expression (not the base type, because it may not be a type), and M1, M2, etc. are metadata elements.


Submitted to the Typing Council: Typing spec update: Improve spec for Annotated · Issue #32 · python/typing-council · GitHub

1 Like