Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

BackrndSource
Copy link
Contributor

This ensures proper delegation to other.__eq__ in case of comparisons with unrelated types and avoid raise AttributeError when trying to compare with objects not having event attribute

@Baekalfen Baekalfen force-pushed the windowevent-fix branch 2 times, most recently from 66912b6 to b1b24c9 Compare February 12, 2025 11:43
Comment on lines +229 to +234
def __eq__(self, other):
if isinstance(other, WindowEvent):
return self.__event == other.__event
elif isinstance(other, int):
return self.__event == other
return NotImplemented
Copy link
Owner

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?

Copy link
Owner

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.

Comment on lines +4 to +5


Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants