Python: Add QL test for comprehensions with unpacking

This commit is contained in:
Taus
2026-04-10 16:09:18 +00:00
parent fc5b3562c3
commit de900fc3b5
3 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
| 3 | ListComp |
| 5 | SetComp |
| 7 | DictComp |
| 9 | GeneratorExp |

View File

@@ -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

View File

@@ -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()