mirror of
https://github.com/github/codeql.git
synced 2026-05-15 03:39:32 +02:00
Python: Consolidate duplicated code
This commit is contained in:
@@ -795,12 +795,7 @@
|
||||
;;;;;; DictComp (`{a: b for c in d if e}`)
|
||||
; See GeneratorExp for details.
|
||||
|
||||
(dictionary_comprehension
|
||||
body: (pair
|
||||
key: (_) @_key
|
||||
value: (_) @_value
|
||||
)
|
||||
) @genexpr
|
||||
(dictionary_comprehension) @genexpr
|
||||
{
|
||||
; Synthesize the `genexpr` function
|
||||
let @genexpr.fun = (ast-node @genexpr "Function")
|
||||
@@ -824,29 +819,6 @@
|
||||
attr (@genexpr.arg_use) ctx = "load"
|
||||
}
|
||||
|
||||
; DictComp with unpacking (PEP 798): `{**d for d in dicts}`
|
||||
(dictionary_comprehension
|
||||
body: (dictionary_splat)
|
||||
) @genexpr
|
||||
{
|
||||
let @genexpr.fun = (ast-node @genexpr "Function")
|
||||
attr (@genexpr.node) function = @genexpr.fun
|
||||
attr (@genexpr.fun) name = "dictcomp"
|
||||
|
||||
let @genexpr.arg = (ast-node @genexpr "Name")
|
||||
attr (@genexpr.arg) variable = ".0"
|
||||
attr (@genexpr.arg) ctx = "param"
|
||||
|
||||
edge @genexpr.fun -> @genexpr.arg
|
||||
attr (@genexpr.fun -> @genexpr.arg) args = 0
|
||||
attr (@genexpr.fun) kwonlyargs = #null
|
||||
attr (@genexpr.fun) kwarg = #null
|
||||
|
||||
let @genexpr.arg_use = (ast-node @genexpr "Name")
|
||||
attr (@genexpr.arg_use) variable = ".0"
|
||||
attr (@genexpr.arg_use) ctx = "load"
|
||||
}
|
||||
|
||||
;;;;;; End of DictComp (`{a: b for c in d if e}`)
|
||||
|
||||
;;;;;; GeneratorExp (`(a for b in c if d)`)
|
||||
|
||||
Reference in New Issue
Block a user