Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-133925: Make typing._UnionGenericAlias hashable#133929
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Lib/typing.py Outdated
def __hash__(self): | ||
return super().__hash__() |
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.
This means that aUnion
instance and a_UnionGenericAlias
instance might compare equal but hash differently, right? Might that do counterintuitive things if you used them as dictionary keys or put them in sets?
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 think that this is purely about the_UnionGenericAlias
class itself, not_UnionGenericAlias
instances.
Btw, do we need to add__hash__
tests to instances in other PR?
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 think that this is purely about the
_UnionGenericAlias
class itself, not_UnionGenericAlias
instances.
ah, thanks, great point. It still seems like users are storing the classes themselves in sets, though, so I think my point still applies -- the bug report here comes fromastropy/astropy#18126
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.
Yes, I should have made it hash() equal to Union. Fixed now.
8d478c7
intopython:mainUh oh!
There was an error while loading.Please reload this page.
Thanks@JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
GH-133936 is a backport of this pull request to the3.14 branch. |
Uh oh!
There was an error while loading.Please reload this page.
typing._UnionGenericAlias
is unhashable in 3.14 #133925