Skip to main content

Module imports

Module imports 

Source
Expand description

Python import syntax, binding, and FQN resolution.

Everything here is a free function over PythonSource; the ImportAnalysisProvider impl that memoizes the per-file results stays on PythonAnalyzer in analyzer/python/imports.rs.

Structs§

PythonImportBinding
PythonModuleReplacement

Enums§

PythonImportDetails

Functions§

extract_package_from_python_wildcard
module_replacement_of
parse_python_import_bindings
Return source-ordered, parser-derived local bindings for explicit Python imports. The byte offset lets callers select the last visible binding rather than treating a whole document as one unordered import scope.
parse_python_import_infos
Parse the structured import facts for a Python document without executing it. LSP model binding uses the same AST-derived representation as the analyzer so external APIs are never selected by a terminal-name scan.
python_import_details
python_import_infos_from_node
python_namespace_binding_module
python_namespace_binding_name
resolve_exported_fqn
resolve_fqn_candidates
Resolve a Python FQN with the cheapest semantically complete tier that can answer it. The direct reexport walk handles only proven, collision-free chains; ambiguous shapes use the ordered export index, and the exact lookup remains the final fallback for non-export symbols.
resolve_import
resolve_import_bindings
resolve_imports_batched
Resolves every import in imports (file’s own imports), batching each import’s primary module FQN lookup (see primary_module_fqn) into one store transaction instead of one per import. Shared by resolve_import_bindings and resolve_import_target_files, the two per-file “resolve everything” entry points – both are called once per candidate file by the usages candidate walker, so unbatched resolution here means one store transaction per import times every file in the workspace.
resolve_python_relative_module
resolve_python_relative_module_from_package
Resolve a structured Python module expression against an already-known package identity. Dependency-pack producers know module identities without owning a workspace ProjectFile, so they use this entry point.