-
-
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
Merged
Merged
gh-116126: Implement PEP 696 #116129
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
e7ca092
gh-116126: Grammar changes for PEP 696
JelleZijlstra 828679e
Fix test_ast
JelleZijlstra d3b472b
new tests
JelleZijlstra 6e467ee
fix test_unparse
JelleZijlstra fa48580
possible solution
JelleZijlstra 49b077b
Can't use the name either
JelleZijlstra 5cfd5e2
blurb
JelleZijlstra 01b3270
should not have pushed that
JelleZijlstra 7a69204
maybe this will compile
JelleZijlstra a265008
Feature version support
JelleZijlstra 0c28297
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra 8aa5b27
default_ -> default_value
JelleZijlstra bdd01bb
ast docs
JelleZijlstra 2c28b9a
more docs
JelleZijlstra b0d467f
Fix typevarobject.c
JelleZijlstra d7e91e2
default=<unrepresentable>
JelleZijlstra 35226b4
NoneType is immortal
JelleZijlstra 2e079ee
Runtime implementation
JelleZijlstra e037052
What's New
JelleZijlstra 7b15f11
Document None/NoneType weirdness
JelleZijlstra 11bd102
fix doctest
JelleZijlstra c54aeed
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra 71a348b
Feedback from Alex
JelleZijlstra 900cd40
Partial work
JelleZijlstra c13420b
Allow * in TypeVarTuple default
JelleZijlstra 8a08c62
Test and fix grammar
JelleZijlstra 613159f
Fix TypeVarTuple substitution
JelleZijlstra 4e0435e
Two more cases
JelleZijlstra 7d54ace
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra 12581d8
Fix TypeVar substitution
JelleZijlstra 2b5a102
Fix ParamSpec
JelleZijlstra a2c48c9
Prohibit default after TypeVarTuple
JelleZijlstra 29b9435
Wrap new syntax in run_code()
JelleZijlstra 326de17
Silence Ruff
JelleZijlstra 6f66775
Fix parameter markup
JelleZijlstra 7efa4ce
default_ -> default_value
JelleZijlstra 29ad843
Fix errors
JelleZijlstra 2c04c14
arguments, not parameters
JelleZijlstra 7d4f3fd
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra 1a14367
Apply suggestions from code review
JelleZijlstra 5890d79
regen clinic
JelleZijlstra 19a7b48
variadic args for _unpack_args
JelleZijlstra ef0616b
Update Lib/typing.py
JelleZijlstra 9d4e842
Update Doc/reference/executionmodel.rst
JelleZijlstra 2686b97
Roundtrip tests
JelleZijlstra 98d1dec
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra fbb6405
Fix doctest
JelleZijlstra e0ccfeb
Add typing.NoDefault as the default for TypeVar's default
JelleZijlstra 15aaff9
Apply suggestions from code review
JelleZijlstra 86f5aed
Add .has_default() and update docs
JelleZijlstra 3e0c0fc
Apply suggestions from code review
JelleZijlstra f5a3d4b
remove trailing space
JelleZijlstra 92ea108
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra 5f6fdfd
Ignore new C globals
JelleZijlstra b3f053c
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra 8c3e0b4
Fix scoping key
JelleZijlstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,8 @@ Interpreter improvements: | |
|
||
New typing features: | ||
|
||
* :pep:`696`: Type parameters (:data:`typing.TypeVar`, :data:`typing.ParamSpec`, | ||
and :data:`typing.TypeVarTuple`) now support defaults. | ||
Comment on lines
+92
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels like a very short description of the changes, considering that it involves a change to CPython's grammar 😃 but we can add a more expansive description later; this is non-blocking |
||
* :pep:`742`: :data:`typing.TypeIs` was added, providing more intuitive | ||
type narrowing behavior. | ||
|
||
|
@@ -850,6 +852,10 @@ typing | |
an item of a :class:`typing.TypedDict` as read-only for type checkers. | ||
See :pep:`705` for more details. | ||
|
||
* Add :data:`typing.NoDefault`, a sentinel object used to represent the defaults | ||
of some parameters in the :mod:`typing` module. (Contributed by Jelle Zijlstra in | ||
:gh:`116126`.) | ||
|
||
unicodedata | ||
----------- | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 useNoDefault
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!