Closed
Description
It's pretty common to have __eq__
with a non-object
argument type, and mypy will just complain that it's not compatible with object
(as object
defines __eq__
with an object
argument). It would be better to display a message that shows how to properly implement __eq__
. Here's an idea (probably needs polish):
x.py:23: error: Argument 1 of "__eq__" incompatible with supertype "object"
x.py:23: note: It's recommended for "__eq__" to work with arbitrary objects.
x.py:23: note: This example shows how you can implement "__eq__":
x.py:23: note:
x.py:23: note: class Foo(...):
x.py:23: note: ...
x.py:23: note: def __eq__(self, other: object) -> bool:
x.py:23: note: if not isinstance(other, Foo):
x.py:23: note: return NotImplemented
x.py:23: note: return <logic to compare equality of two Foo instances>