Python: Fix false positive for cyclic imports guarded by if False:.

This commit is contained in:
Taus Brock-Nannestad
2019-09-27 14:50:03 +02:00
parent 921371d544
commit aa16d20d5a
3 changed files with 8 additions and 1 deletions

View File

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

View File

@@ -1,5 +1,9 @@
from typing import TYPE_CHECKING
if False:
import module1
if TYPE_CHECKING:
import module1
x = 1

View File

@@ -0,0 +1,2 @@
TYPE_CHECKING = False