How to alias Annotated
to a subscriptable type
#779
Labels
topic: feature
Discussions about new features for Python's type annotations
Annotated
to a subscriptable type
#779
Hi, I want to create a type alias that simply wraps a tuple into
Annotated
.PEP 593
I want to be able to write
And get
Among other things, I've tried:
Which mypy is happy with the declaration, but not using it:
Which happens because I guess mypy does not evaluate the type annotation, it just treats
SpecialReturn
as a separate type. I am not sure what is the reasoning behind this, but I assume there it makes sense in some way(?).So, is there any alternative? How do achieve this? I essentially want to alias
Tuple
and be able to find out at runtime if the type is a normal tuple or my special one.My first jab at this, and what I think makes most sense to a Python developer is the following
But mypy can't handle it either:
I was thinking maybe something like this was possible with
Annotated
, but it seems not.The text was updated successfully, but these errors were encountered: