mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Python: Fix false positive for cyclic imports guarded by if False:.
This commit is contained in:
@@ -22,7 +22,8 @@ predicate circular_import(ModuleValue m1, ModuleValue m2) {
|
||||
ModuleValue stmt_imports(ImportingStmt s) {
|
||||
exists(string name |
|
||||
result.importedAs(name) and not name = "__main__" |
|
||||
name = s.getAnImportedModuleName()
|
||||
name = s.getAnImportedModuleName() and
|
||||
s.getASubExpression().pointsTo(result)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if False:
|
||||
import module1
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import module1
|
||||
|
||||
x = 1
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
TYPE_CHECKING = False
|
||||
|
||||
Reference in New Issue
Block a user