Change import
org.openrewrite.python.ChangeImport
Change a Python import from one module/name to another, updating all type attributions.
Recipe source
This recipe is only available to users of Moderne.
This recipe is available under the Moderne Proprietary License.
Options
| Type | Name | Description | Example |
|---|---|---|---|
null | old_module | The module to change imports from | collections |
null | old_name | Optional. The name to change (for 'from X import name' style). Leave empty for direct imports. | Mapping |
null | new_module | The module to change imports to | collections.abc |
null | new_name | Optional. The new name. If not specified, uses the old name. | Mapping |
null | new_alias | Optional. Optional alias for the new import |
Used by
This recipe is used as part of the following composite recipes:
Usage
In order to run Python recipes, you will need to use the Moderne CLI.
Once the CLI is installed, you can install this Python recipe package by running the following command:
Install the recipe package
mod config recipes pip install openrewrite
Then, you can run the recipe via:
Run the recipe
mod run . --recipe org.openrewrite.python.ChangeImport