While updating a project to replace manually-written __eq__() methods with the new #[pyclass(eq)] option added in 0.22, I found that doing so causes a TypeError to be raised when objects of different types are checked for equality. I believe it should return NotImplemented instead, to stay consistent with pyclasses that use __eq__() and standard Python types.
This PR contains the change, and a test to confirm the comparison behavior.
Please let me know how this looks, particularly the tests -- I'm not sure if I got those in the right spot 🙂 Thanks!
While updating a project to replace manually-written
__eq__()
methods with the new#[pyclass(eq)]
option added in 0.22, I found that doing so causes aTypeError
to be raised when objects of different types are checked for equality. I believe it should returnNotImplemented
instead, to stay consistent with pyclasses that use__eq__()
and standard Python types.This PR contains the change, and a test to confirm the comparison behavior.
Please let me know how this looks, particularly the tests -- I'm not sure if I got those in the right spot 🙂 Thanks!