Mypy incorrectly infers that parameters are positional-only for __eq__
methods autogenerated with @dataclass
#12186
Labels
__eq__
methods autogenerated with @dataclass
#12186
For a class decorated with
@dataclass
, mypy assumes that the class's__eq__
method will have the exact same signature asobject.__eq__
. However, this is subtly incorrect. Whereas the signature ofobject.__eq__
isdef __eq__(self, other: object, /) -> bool: ...
, the signature ofMyDataclass.__eq__
isdef __eq__(self, other: object) -> bool: ...
. I.e., for the method auto-generated by@dataclass
, the second argument is positional-or-keyword; whereas the second argument is positional-only forobject.__eq__
.Minimal repro (using mypy 0.931, Python 3.10 -- try it on mypy playground here):
The text was updated successfully, but these errors were encountered: