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

Add equality test #698

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

malthe
Copy link

@malthe malthe commented Mar 20, 2023

This fixes issue #502.

Note that two timezones are equal only if their key (name) is the same string.

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

@@ -58,6 +58,9 @@ def __new__(cls, key: str) -> Timezone:
except zoneinfo.ZoneInfoNotFoundError:
raise InvalidTimezone(key)

def __eq__(self, other: Any) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference in this case?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency. We already use object in other dunder methods and IIRC it's recommended.

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