Merge pull request #21459 from github/tausbn/python-fix-missing-relative-imports

Python: Fix resolution of relative imports from namespace packages
This commit is contained in:
Taus
2026-03-16 14:59:44 +01:00
committed by GitHub
8 changed files with 60 additions and 0 deletions

View File

@@ -17,6 +17,10 @@ private predicate valid_module_name(string name) {
exists(Module m | m.getName() = name)
or
exists(Builtin cmod | cmod.getClass() = Builtin::special("ModuleType") and cmod.getName() = name)
or
// Namespace packages may not have a corresponding Module entity,
// but their names are still valid for the purpose of import resolution.
name = moduleNameFromFile(any(Folder f))
}
/** An artificial expression representing an import */