mirror of
https://github.com/github/codeql.git
synced 2026-04-15 03:54:02 +02:00
Python: Add tests for lazy from ... import * as well
This commit is contained in:
@@ -3,5 +3,7 @@
|
||||
| 4 | Import | lazy |
|
||||
| 5 | Import | lazy |
|
||||
| 6 | Import | lazy |
|
||||
| 9 | Import | normal |
|
||||
| 7 | from l import * | lazy |
|
||||
| 10 | Import | normal |
|
||||
| 11 | Import | normal |
|
||||
| 12 | from w import * | normal |
|
||||
|
||||
@@ -4,7 +4,9 @@ lazy from b import c
|
||||
lazy from d import e as f
|
||||
lazy import g.h as i
|
||||
lazy from ..j import k
|
||||
lazy from l import *
|
||||
|
||||
# Non-lazy imports
|
||||
import x
|
||||
from y import z
|
||||
from w import *
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import python
|
||||
|
||||
string lazy(Import imp) { if imp.isLazy() then result = "lazy" else result = "normal" }
|
||||
string lazy(Stmt s) {
|
||||
if s.(Import).isLazy() or s.(ImportStar).isLazy() then result = "lazy" else result = "normal"
|
||||
}
|
||||
|
||||
from Import imp
|
||||
where imp.getLocation().getFile().getShortName() = "test.py"
|
||||
select imp.getLocation().getStartLine(), imp.toString(), lazy(imp)
|
||||
from Stmt s
|
||||
where
|
||||
s.getLocation().getFile().getShortName() = "test.py" and
|
||||
(s instanceof Import or s instanceof ImportStar)
|
||||
select s.getLocation().getStartLine(), s.toString(), lazy(s)
|
||||
|
||||
Reference in New Issue
Block a user