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

Backport PEP-696 specialisation on Python >=3.11.1 #397

Merged
merged 6 commits into from
May 16, 2024

Conversation

AlexWaygood
Copy link
Member

This is a fix for #396 on Python 3.11 and Python 3.12. Unfortunately, the __typing_prepare_subst__ hook doesn't exist on Python 3.10 and lower, so I'm not sure it's possible to backport it on older versions of Python without monkeypatching typing._GenericAlias.__getitem__, which seems like a bad idea. So maybe we should just document that not all features of PEP-696 are guaranteed to work on Python <=3.10?

@AlexWaygood AlexWaygood changed the title Add failing tests Backport PEP-696 specialisation on Python 3.11 and 3.12 May 16, 2024
Comment on lines +6405 to +6408
@skipIf(
sys.version_info < (3, 11, 1),
"Not yet backported for older versions of Python"
)
Copy link
Member Author

Choose a reason for hiding this comment

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

I verified locally that these tests pass with Python 3.11.1 but not with Python 3.11.0...

Copy link
Member

Choose a reason for hiding this comment

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

It seems like the failures are just that we're missing the defaults from __args__, which doesn't seem too bad. (It may cause problems for introspection but shouldn't usually break creation of types that are normally in annotations.) I'm fine leaving those out for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the test failures "just" indicate incorrect behaviour rather than crashes

@AlexWaygood AlexWaygood changed the title Backport PEP-696 specialisation on Python 3.11 and 3.12 Backport PEP-696 specialisation on Python >=3.11.1 May 16, 2024
@JelleZijlstra JelleZijlstra merged commit 074d053 into python:main May 16, 2024
18 checks passed
@AlexWaygood AlexWaygood deleted the 696-specialisation branch May 16, 2024 16:40
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