Open
Description
Bug Report
I'm creating an ABC
inheriting from an untyped class and override its __init__
function. Then, all child classes are detected as being abstract, even though they are not.
The error is not caused when removing the overriding the init function or removing the inheritance from the untyped base class
To Reproduce
from abc import ABC, abstractmethod
from untyped import Base # type: ignore[import-not-found]
class Abstract(ABC, Base):
def __init__(self):
super().__init__()
@abstractmethod
def method(self) -> None: ...
class Concrete(Abstract):
def method(self) -> None: ...
C: type[Abstract] = Concrete # E: Can only assign concrete classes to a variable of type "type[Abstract]" [type-abstract]
https://mypy-play.net/?mypy=1.11.2&python=3.12&gist=6b11b5a5c3ef54947fb0874cade6ce98
Expected Behavior
This code should not produce any errors as the abstract method is implemented.
Actual Behavior
- main.py:20: error: Can only assign concrete classes to a variable of type "type[Abstract]" [type-abstract]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.11.2 & master
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.12