Closed
Description
Mypy does well with metaclass __getitem__
when the class is instatiated,
but in case of indexing just the child class, it fails:
class Other:
...
class GenMeta(type):
def __getitem__(cls, ref: Type[int]) -> Type[Other]:
return Other
class Gen(metaclass=GenMeta):
...
a = Gen[int] # "Gen" expects no type arguments, but 1 given
reveal_type(a) # Revealed type is 'Any'
b = Gen[int]()
reveal_type(b) # Revealed type is 'pyksp.simple_test.Other'
def foo(arg: Gen[int]) -> None: # "Gen" expects no type arguments, but 1 given
reveal_type(arg) # Revealed type is 'pyksp.simple_test.Gen'
I think it would be very useful to check, especially in case of function annotations
Metadata
Metadata
Assignees
Labels
No labels