Remove Python dependency
MSALRemove a dependency from a Python project. Supports pyproject.toml (with scope/group targeting), requirements.txt, and Pipfile. When unlessImporting is set, a project whose Python sources still import one of those modules keeps the dependency. For pyproject.toml, uv.lock, poetry.lock, and pdm.lock are regenerated natively without executing the package manager. For Pipfile, Pipfile.lock is regenerated natively by consulting the project's package index over the network. Not safe to use as a precondition: consults the package index over the network and publishes per-project state shared with other dependency recipes.
org. openrewrite. python. RemoveDependencyRequired
The PyPI package name to remove.
Optional
The dependency scope to remove from. All scopes are searched by default.
The group name, required when scope is project.optional-dependencies or dependency-groups.
Keep the dependency in a project where a Python source file still imports one of these modules, matched the way org.openrewrite.python.search.UsesImport matches it, so a submodule counts too. A file is attributed to the nearest dependency file above it that declares the package. Imports are read as they stand at the start of each cycle, so in a migration the dependency goes in the cycle after the last import of it is migrated. Name the modules the package provides, such as async_timeout for async-timeout. Leave unset to remove the dependency unconditionally. Separate values with commas.
mod run . --recipe= org. openrewrite. python. RemoveDependency \
-P packageName= requestsInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.