Closed
Description
Bug Report
Adding a third ABC
to a list of types in a for
loop causes a Mypy type checking false positive error.
In the code below, if you remove the second C2
there is no error, but adding a third ABC
to the iteration for some reason triggers this error.
To Reproduce
from abc import ABC, abstractmethod
class Base(ABC):
@abstractmethod
def a(self) -> None:
...
class C1(Base):
def a(self) -> None:
return
class C2(Base):
def a(self) -> None:
return
for c in (C1, C2, C2):
c()
Expected Behavior
No type check error.
Actual Behavior
Produces false positive type check error:
main.py:24: error: Cannot instantiate abstract class "Abstract" with abstract attribute "a" [abstract]
Your Environment
- Mypy version used: 1.7.0
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini
(and other config files):
[tool.mypy]
strict = true
- Python version used: 3.10.11