You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mypy mistakenly does not recognize __init_subclass__ of parent class if defined in a different module.
child.py:4: error: Unexpected keyword argument "flag" for "__init_subclass__" of "object"
To Reproduce
parent.py:
classB:
@classmethoddef__init_subclass__(cls, /, flag: bool=False, **kwargs):
# until https://github.com/python/mypy/issues/4660 is fixedsuper().__init_subclass__(**kwargs) # type: ignore[call-arg]
child.py:
from .parentimportBclassA(B, flag=True):
pass
Expected Behavior
Mypy should recognize that A inherits from B and thus understand that it overrides the default __init_subclass__.
It already does so if they are both located in the same module.
Your Environment
Mypy version used: mypy 0.790
Mypy command-line flags: mypy child.py
Mypy configuration options from mypy.ini (and other config files):
Bug Report
Mypy mistakenly does not recognize
__init_subclass__
of parent class if defined in a different module.child.py:4: error: Unexpected keyword argument "flag" for "__init_subclass__" of "object"
To Reproduce
parent.py:
child.py:
Expected Behavior
Mypy should recognize that
A
inherits fromB
and thus understand that it overrides the default__init_subclass__
.It already does so if they are both located in the same module.
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: