Bug Report
I am experienced a very weird behavior (which I am now pretty sure is a bug) with __class_getitem__.
To Reproduce
from abc import abstractmethod
from typing import Iterable
class A(Iterable):
@abstractmethod
def __class_getitem__(cls, item):
...
class B(A):
def f(self, field: str):
self.__class__[str]
>>> attribute.py:14: error: Value of type "Type[B]" is not indexable [index]
Here I expect that mypy know that __class__ is bounded by the class B and therefore implement __class_getitem__.
The weirdest part is that removing the parameter in f remove the problem
from abc import abstractmethod
from typing import Iterable
class A(Iterable):
@abstractmethod
def __class_getitem__(cls, item):
...
class B(A):
def f(self):
self.__class__[str]
>>> Success: no issues found in 1 source file
Expected Behavior
mypy recognize that class can be indexed
Actual Behavior
mypy said it is no indexable even though B implement __class_getitem__
Your Environment
FYI: a more advance setup in this PR docarray/docarray#803
Bug Report
I am experienced a very weird behavior (which I am now pretty sure is a bug) with
__class_getitem__.To Reproduce
Here I expect that mypy know that
__class__is bounded by the class B and therefore implement__class_getitem__.The weirdest part is that removing the parameter in
fremove the problemExpected Behavior
mypy recognize that class can be indexed
Actual Behavior
mypy said it is no indexable even though B implement
__class_getitem__Your Environment
Mypy version used: 0.990
Mypy command-line flags: None
Mypy configuration options from
mypy.ini(and other config files): plugins = "pydantic.mypy"Python version used: 3.9
FYI: a more advance setup in this PR docarray/docarray#803