Bug Report
Self as return type annotation in base class method breaks multi-inheritance.
(A clear and concise description of what the bug is.)
To Reproduce
importcopyfromtypingimportSelfclassCloneable:
defclone(self) ->Self:
returncopy.copy(self)
classImmutable:
defclone(self) ->Self:
returnselfclassCollection(Cloneable):
passclassTuple(Immutable, Collection):
pass
Expected Behavior
No errors
Actual Behavior
error: Definitionof"clone"inbaseclass"Immutable"isincompatiblewithdefinitioninbaseclass"Cloneable" [misc]
Same code using old approach woks as expected:
importcopyfromtypingimportTypeVar_Self=TypeVar("_Self")
classCloneable:
defclone(self: _Self) ->_Self:
returncopy.copy(self)
classImmutable:
defclone(self: _Self) ->_Self:
returnselfclassCollection(Cloneable):
passclassTuple(Immutable, Collection):
passpyright doesn't raise an error.
Your Environment
- Mypy version used: 1.0.0
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini (and other config files): - Python version used: 3.11
Bug Report
Selfas return type annotation in base class method breaks multi-inheritance.(A clear and concise description of what the bug is.)
To Reproduce
Expected Behavior
No errors
Actual Behavior
Same code using old approach woks as expected:
pyrightdoesn't raise an error.Your Environment
mypy.ini(and other config files):