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

Fix reliance on unspecified behavior in test_disambiguators.py #642

Merged
merged 1 commit into from
Mar 31, 2025

Conversation

JelleZijlstra
Copy link
Contributor

See python/cpython#131933. Python does not guarantee that running Union[A, B] twice gives the same object back. This test is currently broken in Python 3.14 main.

See python/cpython#131933. Python does not guarantee that running `Union[A, B]` twice gives the same object back. This test is currently broken in Python 3.14 main.
@Tinche
Copy link
Member

Tinche commented Mar 31, 2025

Cool, thanks. I wonder if there's user code in the wild that relies on this behavior though - cattrs supports matching types by predicate functions, so folks might have working predicates that use is instead of ==.

Taking a broader view, it's also just a little unfortunate in that int is int and list is list, but list[int] is not list[int].

@Tinche Tinche merged commit 0c36adc into python-attrs:main Mar 31, 2025
11 checks passed
@JelleZijlstra
Copy link
Contributor Author

Thanks for merging the PR!

Taking a broader view, it's also just a little unfortunate in that int is int and list is list, but list[int] is not list[int].

Possibly, but I don't think this is terribly inconsistent with how Python works in general. It's also true that (int, int) is not (int, int), and int | str is not int | str.

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