-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
PEP 560 defines __class_getitem__
as a way to enable indexing a class (to define custom generic types for instance), but mypy
does not seem to recognize this.
To Reproduce
$ cat test.py
class A:
def __class_getitem__(cls, item):
return cls
x = A[int]
$ mypy test.py
Expected Behavior
Success: no issues found in 1 source file
Actual Behavior
test.py:6: error: "A" expects no type arguments, but 1 given
Found 2 errors in 1 file (checked 1 source file)
Environment
- mypy 0.910
- Python 3.9.7
- Darwin arm64
KotlinIsland, DetachHead, Fleex255, jamesbraza, samuelcolvin and 9 more