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
For a class decorated with @dataclass, mypy assumes that the class's __eq__ method will have the exact same signature as object.__eq__. However, this is subtly incorrect. Whereas the signature of object.__eq__ is def __eq__(self, other: object, /) -> bool: ..., the signature of MyDataclass.__eq__ is def __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 for object.__eq__.
Minimal repro (using mypy 0.931, Python 3.10 -- try it on mypy playground here):
fromdataclassesimportdataclass@dataclassclassFoo: ...
reveal_type(Foo.__eq__) # Revealed type is "def (builtins.object, builtins.object) -> builtins.bool"