Python: Support unpacking in comprehensions in tree-sitter-python

This is the easy part -- we just allow `dictionary_splat` or
`list_splat` to appear in the same place as the expression.
This commit is contained in:
Taus
2026-04-10 15:52:33 +00:00
parent c748fdf8ee
commit 4b5ff0b89e

View File

@@ -1031,28 +1031,28 @@ module.exports = grammar({
list_comprehension: $ => seq(
'[',
field('body', $.expression),
field('body', choice($.expression, $.list_splat)),
$._comprehension_clauses,
']'
),
dictionary_comprehension: $ => seq(
'{',
field('body', $.pair),
field('body', choice($.pair, $.dictionary_splat)),
$._comprehension_clauses,
'}'
),
set_comprehension: $ => seq(
'{',
field('body', $.expression),
field('body', choice($.expression, $.list_splat)),
$._comprehension_clauses,
'}'
),
generator_expression: $ => seq(
'(',
field('body', $.expression),
field('body', choice($.expression, $.list_splat)),
$._comprehension_clauses,
')'
),