Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
JelleZijlstra merged 2 commits intopython:mainfromJelleZijlstra:unionhash
May 12, 2025

Conversation

JelleZijlstra
Copy link
Member

@JelleZijlstraJelleZijlstra commentedMay 12, 2025
edited by bedevere-appbot
Loading

neutrinoceros reacted with rocket emoji
Lib/typing.py Outdated
Comment on lines 1652 to 1653
def __hash__(self):
return super().__hash__()
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member

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

Copy link
MemberAuthor

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.

AlexWaygood reacted with thumbs up emoji
@JelleZijlstraJelleZijlstra added the needs backport to 3.14bugs and security fixes labelMay 12, 2025
@JelleZijlstraJelleZijlstra merged commit8d478c7 intopython:mainMay 12, 2025
45 checks passed
@miss-islington-app
Copy link

Thanks@JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 12, 2025
…3929)(cherry picked from commit8d478c7)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@bedevere-app
Copy link

GH-133936 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelMay 12, 2025
JelleZijlstra added a commit that referenced this pull requestMay 12, 2025
…#133936)gh-133925: Make typing._UnionGenericAlias hashable (GH-133929)(cherry picked from commit8d478c7)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sobolevnsobolevnsobolevn approved these changes

@AlexWaygoodAlexWaygoodAlexWaygood approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@JelleZijlstra@sobolevn@AlexWaygood

[8]ページ先頭

©2009-2025 Movatter.jp