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
PythonImportSyntax
One import leaf interpreted directly from the Python AST.
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_assignment_chain
Flatten a right-recursive assignment into its targets and terminal value. Targets are returned in runtime order, followed by the single evaluated right-hand expression.
python_function_scoped_import_binding
Select the latest visible function-scoped import binding for name.
python_import_bindings_from_imports
Build import bindings from the canonical generic import projection.
python_import_bindings_from_tree
Return structured import bindings from a tree the caller already owns. Query paths use this form so one request never reparses a document merely to recover function-local import scope.
python_import_details
python_import_infos_from_node
python_import_syntaxes_from_node
Interpret every import leaf in one statement and retain its exact AST binder nodes. Malformed leaves are omitted with the same admission rules as the historical generic import projection.
python_local_module_alias_path_before
Resolve a local name assigned a module object before reference.
python_namespace_binding_module
python_namespace_binding_name
resolve_exported_fqn
importer, when known, is the file whose import statement asked for fqn; its own import root is what decides between two same-named modules. None is for an FQN-level question no import statement asked.
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_import_files_batched
Resolve Python imports to the workspace files whose modules they execute.
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_module_specifier
Resolve a relative Python module specifier against the importing file.
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.