Closed
Description
When using a TypeAliasType
without type_params it should raise an error which it currently doesn't:
from typing import TypeAliasType as typing_TA
from typing_extensions import TypeAliasType
# this should raise an error
Simple = TypeAliasType("Simple", int)
Simple_typing = typing_TA("Simple", int)
try:
Simple[str] # No TypeError
except TypeError:
print("TypeError raised like expected")
else:
print("No type error was raised.") # <-- will be printed
Simple_typing[str] # will raise TypeError
However, currently in 3.12+ when using type_params=()
the code unexpectedly allows subscription.
See also cpython issue #124498 and its PR. This issue likely needs an upstream decision first if the following case is intended or a bug:
from typing import TypeAliasType as typing_TA
Simple2 = typing_TA("Simple", int, type_params=())
Simple2[str] # no type error for typing.TypeAliasType
Also related:
Metadata
Metadata
Assignees
Labels
No labels