You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type MyAlias=ClassVar[int]
@my_dataclassclassA:
f: Annotated[MyAlias, "meta_1"]
Static type checkers raise an error on the MyAlias definition, as type qualifiers can only be used in certain contexts (in the case of ClassVar, it can only be used within a class annotation).
When passing Annotated[MyAlias, "meta_1"] to inspect_annotation() (and setting unpack_type_aliases to 'eager'), we currently don't error:
In the
introspection
module, theinspect_annotation()
function can be used to unpack the underlying type expression:However, the passed annotation expression could be defined as:
Static type checkers raise an error on the
MyAlias
definition, as type qualifiers can only be used in certain contexts (in the case ofClassVar
, it can only be used within a class annotation).When passing
Annotated[MyAlias, "meta_1"]
toinspect_annotation()
(and settingunpack_type_aliases
to'eager'
), we currently don't error:Should we error whenever a type qualifier is used inside a PEP 695 type alias? Or provide an option to (dis)allow it/raise a warning?
The text was updated successfully, but these errors were encountered: