Skip to content

Commit 6c675fc

Browse files
committed
Python: Consolidate duplicated code
1 parent 8b1ecf0 commit 6c675fc

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

python/extractor/tsg-python/python.tsg

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -795,12 +795,7 @@
795795
;;;;;; DictComp (`{a: b for c in d if e}`)
796796
; See GeneratorExp for details.
797797

798-
(dictionary_comprehension
799-
body: (pair
800-
key: (_) @_key
801-
value: (_) @_value
802-
)
803-
) @genexpr
798+
(dictionary_comprehension) @genexpr
804799
{
805800
; Synthesize the `genexpr` function
806801
let @genexpr.fun = (ast-node @genexpr "Function")
@@ -824,29 +819,6 @@
824819
attr (@genexpr.arg_use) ctx = "load"
825820
}
826821

827-
; DictComp with unpacking (PEP 798): `{**d for d in dicts}`
828-
(dictionary_comprehension
829-
body: (dictionary_splat)
830-
) @genexpr
831-
{
832-
let @genexpr.fun = (ast-node @genexpr "Function")
833-
attr (@genexpr.node) function = @genexpr.fun
834-
attr (@genexpr.fun) name = "dictcomp"
835-
836-
let @genexpr.arg = (ast-node @genexpr "Name")
837-
attr (@genexpr.arg) variable = ".0"
838-
attr (@genexpr.arg) ctx = "param"
839-
840-
edge @genexpr.fun -> @genexpr.arg
841-
attr (@genexpr.fun -> @genexpr.arg) args = 0
842-
attr (@genexpr.fun) kwonlyargs = #null
843-
attr (@genexpr.fun) kwarg = #null
844-
845-
let @genexpr.arg_use = (ast-node @genexpr "Name")
846-
attr (@genexpr.arg_use) variable = ".0"
847-
attr (@genexpr.arg_use) ctx = "load"
848-
}
849-
850822
;;;;;; End of DictComp (`{a: b for c in d if e}`)
851823

852824
;;;;;; GeneratorExp (`(a for b in c if d)`)

0 commit comments

Comments
 (0)