-
I just upgraded some code to python 3.10, and auto-upgraded type hints to use non-aliased types where possible. So, for instance I have some code that does reflection on type annotations, through This difference can be seen by executing the following code: from typing import Dict
from typing import Generic
from typing import Tuple
from typing import TypeVar
T = TypeVar("T")
class SomeContainer(Generic[T]):
v: T
class Foo:
x: dict[str, "Baz"]
y: tuple["Baz"]
z: SomeContainer["Baz"]
class Bar:
x: Dict[str, "Baz"]
y: Tuple["Baz"]
z: SomeContainer["Baz"]
class Baz:
pass
print(Foo.__annotations__)
print(Bar.__annotations__) For instance, the annotation My user-defined generic In other words, it seems that the construction of Is this intentional, or is this a bug? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
What does get_type_hints give for each case? I think get_type_hints is the public api way to examine annotations. Using |
Beta Was this translation helpful? Give feedback.
-
I think you might be interested in python/cpython#85542 |
Beta Was this translation helpful? Give feedback.
I think you might be interested in python/cpython#85542