Skip to content

Fix reliance on unspecified behavior in test_disambiguators.py - #642

Merged
Tinche merged 1 commit into
python-attrs:mainfrom
JelleZijlstra:patch-1
Mar 31, 2025
Merged

Tinche merged 1 commit into
python-attrs:mainfrom
JelleZijlstra:patch-1

Conversation

@JelleZijlstra

Copy link
Copy Markdown
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

Tinche commented Mar 31, 2025

Copy link
Copy Markdown
Member

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
@JelleZijlstra

Copy link
Copy Markdown
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