Consider the following code, written for Python 3.12 (leveraging PEP-695):
import typingtype Animal = typing.Literal["dog", "cat"]def enum_values(t: typing.TypeAliasType) -> typing.Sequence[str]: target = typing.cast(typing.Literal, t.__value__) return typing.get_args(target)print(repr(enum_values(Animal)))When invoked, it properly emits as output:
('dog', 'cat')but it fails type checking with pyright:
testme.py:9:24 - error: Argument of type "Animal" cannot be assigned to parameter "t" of type "TypeAliasType" in function "enum_values" Type "Animal" cannot be assigned to type "TypeAliasType" "type[type]" is incompatible with "type[TypeAliasType]" (reportGeneralTypeIssues)1 error, 0 warnings, 0 informationsHow would a correct type signature for that function be written?