mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Python: Disregard packages when looking for cyclic imports.
This commit is contained in:
@@ -21,7 +21,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() and
|
||||
s.getASubExpression().pointsTo(result)
|
||||
s.getASubExpression().pointsTo(result) and
|
||||
not result.isPackage()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,11 @@ class ModuleValue extends Value {
|
||||
PointsToInternal::module_imported_as(this, name)
|
||||
}
|
||||
|
||||
/** Whether this module is a package. */
|
||||
predicate isPackage() {
|
||||
this instanceof PackageObjectInternal
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module Module {
|
||||
|
||||
Reference in New Issue
Block a user