-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update WindowEvent.__eq__ #366
base: master
Are you sure you want to change the base?
Conversation
66912b6
to
b1b24c9
Compare
def __eq__(self, other): | ||
if isinstance(other, WindowEvent): | ||
return self.__event == other.__event | ||
elif isinstance(other, int): | ||
return self.__event == other | ||
return NotImplemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it's correct to do return NotImplemented
. Can you write a test case that demonstrates it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly, add a test case that demonstrates that not only a == b
works, but also b == a
. This is probably done at the same time.
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the initial test case, as it was testing internal functionality. I've corrected this by changing the code where the internal variable was erroneously used.
b1b24c9
to
b3180a8
Compare
This ensures proper delegation to
other.__eq__
in case of comparisons with unrelated types and avoid raiseAttributeError
when trying to compare with objects not havingevent
attribute