- Notifications
You must be signed in to change notification settings - Fork263
Is there a way to parametrizetyping.Annotated
s metadata?#2023
-
I am trying to make a type that behaves as A naive first approach might look something like this: fromtypingimportTypeVar,Annotated,TypeAlias,Literal_RuntimeType_co=TypeVar("_RuntimeType_co",covariant=True,bound=int,default=int)IntMeta:TypeAlias=Annotated[int,_RuntimeType_co]custom_int:IntMeta[Literal[2]]=2 Of course this does not work, since type checkers will see So, my question: is this possible in any way - whether using |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 1 reply
-
Linkingpython/mypy#18925 for related discussion |
BetaWas this translation helpful?Give feedback.
All reactions
-
Ah, thanks! Looks like the type alias approach falls flat then. I kind of expected this, but a little disappointing nonetheless. |
BetaWas this translation helpful?Give feedback.