Skip to main content

python_import_root

Function python_import_root 

Source
pub fn python_import_root(project: &dyn Project, file: &ProjectFile) -> PathBuf
Expand description

The directory file’s path-derived Python module name is relative to: the analyzer’s stand-in for the sys.path entry an absolute import of that module would be resolved against.

It is the nearest configured setuptools import root, else the parent of the outermost __init__.py package chain above the file, else the project root. The result is always a prefix of the file’s own relative path, and it is what makes two same-named modules in one snapshot distinguishable: registry/purview-registry/registry/models.py and registry/sql-registry/registry/models.py are both the module registry.models, but they belong to different roots (#3475).