mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
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:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
category: fix
|
||||
---
|
||||
|
||||
- Fixed the resolution of relative imports such as `from . import helper` inside namespace packages (directories without an `__init__.py` file), which previously did not work correctly, leading to missing flow.
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user