-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Conversation
@skipIf( | ||
sys.version_info < (3, 11, 1), | ||
"Not yet backported for older versions of Python" | ||
) |
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 verified locally that these tests pass with Python 3.11.1 but not with Python 3.11.0...
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.
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.
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, the test failures "just" indicate incorrect behaviour rather than crashes
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 monkeypatchingtyping._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?