-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-116126: Implement PEP 696 #116129
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
gh-116126: Implement PEP 696 #116129
Conversation
This should be ready for review now, I'll take it out of draft once the tests pass. Notes:
|
Will review this weekend |
@pablogsal have you had a chance to look at this? The grammar changes should be quite straightforward, so hopefully it's not complicated to review. I'll spend some time today trying to make it so the field is called "default" not "default_" in Python, because having "default_" in the Python-visible APIs would be ugly. |
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
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 would say "is not the typing.NoDefault
singleton" rather than "is not equal to typing.NoDefault
", since we usually argue that an identity check is more idiomatic for singleton objects such as None
, NotImplemented
and Ellipsis
>>> T.__default__ is typing.NoDefault | ||
True | ||
>>> S = TypeVar("S", default=None) | ||
>>> S.__default__ is None | ||
True |
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.
>>> T.__default__ is typing.NoDefault | |
True | |
>>> S = TypeVar("S", default=None) | |
>>> S.__default__ is None | |
True | |
>>> T.has_default() | |
False | |
>>> T.__default__ is typing.NoDefault | |
True | |
>>> S = TypeVar("S", default=None) | |
>>> S.has_default() | |
True | |
>>> S.__default__ is None | |
True |
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 thought of that but it felt out of place in the docs for NoDefault
, since the cases you added don't use NoDefault
at all.
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.
Fair enough -- I thought it was quite nice to see together in one example how the two concepts interrelate, but I definitely don't feel strongly!
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@ericsnowcurrently the C globals check is failing because this PR now adds a new static type and global singleton, |
For now let's just whitelist the new singleton, as long as it is stateless and immortal. We can circle back later if the whitelist is a problem. |
🤖 New build scheduled with the buildbot fleet by @JelleZijlstra for commit 5f6fdfd 🤖 If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again. |
The previous logic would add the size of the pointer target to the pointer value, which might point to another pointer being used as a scope key. Now, we increment the value as an integer instead, which means it can never be a valid pointer.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This implements both the grammar and compiler changes and changes to
typing.py
behavior (the latter copied from typing-extensions).