mirror of
https://github.com/github/codeql.git
synced 2026-05-14 11:19:27 +02:00
Python: Add QL test for comprehensions with unpacking
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
| 3 | ListComp |
|
||||
| 5 | SetComp |
|
||||
| 7 | DictComp |
|
||||
| 9 | GeneratorExp |
|
||||
@@ -0,0 +1,12 @@
|
||||
# PEP 798: Unpacking in comprehensions
|
||||
|
||||
flat_list = [*x for x in nested]
|
||||
|
||||
flat_set = {*x for x in nested}
|
||||
|
||||
merged = {**d for d in dicts}
|
||||
|
||||
gen = (*x for x in nested)
|
||||
|
||||
# Force the new parser (the old parser cannot handle lazy imports)
|
||||
lazy import _pep798_parser_hint
|
||||
@@ -0,0 +1,12 @@
|
||||
import python
|
||||
|
||||
from Expr e
|
||||
where
|
||||
e.getLocation().getFile().getShortName() = "test.py" and
|
||||
(
|
||||
e instanceof ListComp or
|
||||
e instanceof SetComp or
|
||||
e instanceof DictComp or
|
||||
e instanceof GeneratorExp
|
||||
)
|
||||
select e.getLocation().getStartLine(), e.toString()
|
||||
Reference in New Issue
Block a user