Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
gh-116126: Implement PEP 696#116129
Changes from1 commit
Commits
Show all changes
56 commits Select commitHold shift + click to select a range
e7ca092 gh-116126: Grammar changes for PEP 696
JelleZijlstra828679e Fix test_ast
JelleZijlstrad3b472b new tests
JelleZijlstra6e467ee fix test_unparse
JelleZijlstrafa48580 possible solution
JelleZijlstra49b077b Can't use the name either
JelleZijlstra5cfd5e2 blurb
JelleZijlstra01b3270 should not have pushed that
JelleZijlstra7a69204 maybe this will compile
JelleZijlstraa265008 Feature version support
JelleZijlstra0c28297 Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra8aa5b27 default_ -> default_value
JelleZijlstrabdd01bb ast docs
JelleZijlstra2c28b9a more docs
JelleZijlstrab0d467f Fix typevarobject.c
JelleZijlstrad7e91e2 default=<unrepresentable>
JelleZijlstra35226b4 NoneType is immortal
JelleZijlstra2e079ee Runtime implementation
JelleZijlstrae037052 What's New
JelleZijlstra7b15f11 Document None/NoneType weirdness
JelleZijlstra11bd102 fix doctest
JelleZijlstrac54aeed Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra71a348b Feedback from Alex
JelleZijlstra900cd40 Partial work
JelleZijlstrac13420b Allow * in TypeVarTuple default
JelleZijlstra8a08c62 Test and fix grammar
JelleZijlstra613159f Fix TypeVarTuple substitution
JelleZijlstra4e0435e Two more cases
JelleZijlstra7d54ace Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra12581d8 Fix TypeVar substitution
JelleZijlstra2b5a102 Fix ParamSpec
JelleZijlstraa2c48c9 Prohibit default after TypeVarTuple
JelleZijlstra29b9435 Wrap new syntax in run_code()
JelleZijlstra326de17 Silence Ruff
JelleZijlstra6f66775 Fix parameter markup
JelleZijlstra7efa4ce default_ -> default_value
JelleZijlstra29ad843 Fix errors
JelleZijlstra2c04c14 arguments, not parameters
JelleZijlstra7d4f3fd Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra1a14367 Apply suggestions from code review
JelleZijlstra5890d79 regen clinic
JelleZijlstra19a7b48 variadic args for _unpack_args
JelleZijlstraef0616b Update Lib/typing.py
JelleZijlstra9d4e842 Update Doc/reference/executionmodel.rst
JelleZijlstra2686b97 Roundtrip tests
JelleZijlstra98d1dec Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstrafbb6405 Fix doctest
JelleZijlstrae0ccfeb Add typing.NoDefault as the default for TypeVar's default
JelleZijlstra15aaff9 Apply suggestions from code review
JelleZijlstra86f5aed Add .has_default() and update docs
JelleZijlstra3e0c0fc Apply suggestions from code review
JelleZijlstraf5a3d4b remove trailing space
JelleZijlstra92ea108 Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra5f6fdfd Ignore new C globals
JelleZijlstrab3f053c Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstra8c3e0b4 Fix scoping key
JelleZijlstraFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
possible solution
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitfa48580c2c17f69bb9c7641d7899501d91e80561
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2285,13 +2285,11 @@ symtable_visit_expr(struct symtable *st, expr_ty e) | ||
| } | ||
| static int | ||
| symtable_visit_type_param_bound_or_default(struct symtable *st, expr_ty e, identifier name, void *key) | ||
| { | ||
| if (e) { | ||
| int is_in_class = st->st_cur->ste_can_see_class_scope; | ||
| if (!symtable_enter_block(st, name, TypeVarBoundBlock, key, LOCATION(e))) | ||
| return 0; | ||
| st->st_cur->ste_can_see_class_scope = is_in_class; | ||
| if (is_in_class && !symtable_add_def(st, &_Py_ID(__classdict__), USE, LOCATION(e))) { | ||
| @@ -2316,21 +2314,32 @@ symtable_visit_type_param(struct symtable *st, type_param_ty tp) | ||
| case TypeVar_kind: | ||
| if (!symtable_add_def(st, tp->v.TypeVar.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) | ||
| VISIT_QUIT(st, 0); | ||
| // We must use a different key for the bound and default. The obvious choice would be to | ||
| // use the .bound and .default_ pointers, but that fails when the expression immediately | ||
JelleZijlstra marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| // inside the bound or default is a comprehension: we would reuse the same key for | ||
| // the comprehension scope. Therefore, use the name of the type parameter as the second key. | ||
| // The only requirement for the key is that it is unique and it matches the logic in | ||
| // compile.c where the scope is retrieved. | ||
| if (!symtable_visit_type_param_bound_or_default(st, tp->v.TypeVar.bound, tp->v.TypeVar.name, | ||
| (void *)tp)) | ||
| VISIT_QUIT(st, 0); | ||
| if (!symtable_visit_type_param_bound_or_default(st, tp->v.TypeVar.default_, tp->v.TypeVar.name, | ||
| (void *)tp->v.TypeVar.name)) | ||
| VISIT_QUIT(st, 0); | ||
| break; | ||
| case TypeVarTuple_kind: | ||
| if (!symtable_add_def(st, tp->v.TypeVarTuple.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) | ||
| VISIT_QUIT(st, 0); | ||
| if (!symtable_visit_type_param_bound_or_default(st, tp->v.TypeVarTuple.default_, tp->v.TypeVarTuple.name, | ||
| (void *)tp)) | ||
| VISIT_QUIT(st, 0); | ||
| break; | ||
| case ParamSpec_kind: | ||
| if (!symtable_add_def(st, tp->v.ParamSpec.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) | ||
| VISIT_QUIT(st, 0); | ||
| if (!symtable_visit_type_param_bound_or_default(st, tp->v.ParamSpec.default_, tp->v.ParamSpec.name, | ||
| (void *)tp)) | ||
| VISIT_QUIT(st, 0); | ||
| break; | ||
| } | ||
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.