Skip to main content

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

TypeNameDescriptionExample
nullold_moduleThe module to change imports fromcollections
nullold_nameOptional. The name to change (for 'from X import name' style). Leave empty for direct imports.Mapping
nullnew_moduleThe module to change imports tocollections.abc
nullnew_nameOptional. The new name. If not specified, uses the old name.Mapping
nullnew_aliasOptional. 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