ml_switcheroo.core.import_fixer¶
Import Fixer Package.
This package provides the ImportFixer class, a LibCST transformer responsible for:
1. Injection: Adding required imports for the target framework.
2. Pruning: Removing unused imports from the source framework.
3. Refinement: Collapsing aliases and cleaning up re-exports.
It uses ImportResolver to pre-calculate necessary changes before transformation.
Submodules¶
Classes¶
The strategy for the ImportFixer to execute. |
|
Represents a normalized import requirement. |
|
Composite Transformer for managing imports and namespacing. |
Package Contents¶
- class ml_switcheroo.core.import_fixer.ImportResolver(semantics: ml_switcheroo.semantics.manager.SemanticsManager)[source]¶
- semantics¶
- resolve(tree: libcst.Module, target_fw: str) ResolutionPlan[source]¶
- class ml_switcheroo.core.import_fixer.ResolutionPlan[source]¶
The strategy for the ImportFixer to execute.
- path_to_alias: Dict[str, str]¶
- class ml_switcheroo.core.import_fixer.ImportReq[source]¶
Represents a normalized import requirement. Can represent import module as alias or from module import sub as alias.
- module: str¶
- subcomponent: str | None = None¶
- alias: str | None = None¶
- property signature: str¶
Unique signature for deduplication.
- class ml_switcheroo.core.import_fixer.ImportFixer[source]¶
Bases:
attributes_mixin.AttributeMixin,imports_mixin.ImportMixin,injection_mixin.InjectionMixin,base.BaseImportFixerComposite Transformer for managing imports and namespacing.
Inherits functionality from: -
AttributeMixin: simplifying dotted attribute access. -ImportMixin: rewriting import statements using the plan. -InjectionMixin: injecting missing top-level imports from the plan. -BaseImportFixer: State management and configuration.