Repository navigation
feat: support PEP 798 unpacking comprehensions - #353
Open
StudentWeis wants to merge 1 commit into
Open
StudentWeis wants to merge 1 commit into
StudentWeis wants to merge 1 commit into
Conversation
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Python 3.15 permits unpacking in comprehension bodies, but tuple operands such as
[*("prefix", x) for x in xs]and dictionary unpacking such as{**x for x in xs}currently produceERRORnodes instead of comprehension trees. Allowlist_splatbodies in list/set comprehensions and generator expressions, anddictionary_splatbodies in dictionary comprehensions.Fixes #352.
The handwritten grammar change is four lines, following the focused approach linked in the PEP 798 discussion. It leaves the general
list_splat_patternrule unchanged (unlike the broader changes in #320).Four corpus cases cover 14 expressions: identifier, tuple and call operands, dictionary unpacking, filters, multiple
forclauses, async comprehensions, and a generator used as the sole call argument. The existingListsexpectations are also corrected:[*a.b],[*a[b].c], and[*a()]now place the complete expression insidelist_splat, rather than treating the splat as the attribute receiver or callee (related to #314).Generated files are included, regenerated with CLI 0.25.9 to match the repository. The large
parser.cdiff is generated parse-table churn; a second generation reproduces all three generated files byte-for-byte.Validation on Linux x86_64:
tree-sitter test: all 121 corpus cases pass; 34 highlighting assertions and 5 tag assertions pass.cargo test --locked: Rust binding test and doctest pass.npm run lintandgit diff --check: pass.Node/Python/Go/Swift binding tests and the external example repositories were not run locally.