openrewrite
OpenRewrite automated refactoring for Python.
What it is and what it does
OpenRewrite Python is a framework for writing automated code refactoring recipes that transform Python source code. It provides a lossless semantic tree representation of Python code, a recipe authoring API using dataclasses and visitor patterns, and a test harness for validating transformations before deployment. Recipes are written in pure Python and unit-tested locally, but execution against real codebases is orchestrated by the JVM runtime via the Moderne CLI over an RPC bridge—there is no standalone in-process parser.
The package is designed for teams that need to apply large-scale, consistent code transformations across Python repositories. Typical use involves subclassing the Recipe class, implementing a visitor that traverses and modifies the tree, and registering the recipe with the Moderne CLI marketplace. The test harness lets you verify transformations on code snippets before running them at scale.
Use it for:
- Rename function calls or refactor APIs across a large codebase without manual edits.
- Migrate deprecated library calls to their modern equivalents automatically.
- Enforce code style or naming conventions by applying transformations to all matching patterns.
- Delete or replace obsolete code patterns in batch across multiple repositories.
- Author and test custom refactoring recipes for domain-specific code transformations.
- Build a marketplace of reusable recipes for your organization's refactoring needs.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
OpenRewrite Python provides a framework for authoring and testing automated refactoring recipes that transform Python source code using a lossless semantic tree representation.
Yes, if you need to author and test Python refactoring recipes and have access to the Moderne CLI infrastructure. The package is actively maintained, has no known vulnerabilities, and low install friction. However, verify that the Moderne Source Available License terms suit your use case, and confirm that your deployment environment can support the JVM runtime requirement for executing recipes at scale.
Install
openrewrite on PyPI
pip
pip install openrewriteuv
uv add openrewritepoetry
poetry add openrewriteInstalling openrewrite
Before you install
Active maintenance with a recent release and no known vulnerabilities. Low install friction with three lightweight runtime dependencies. Requires Python 3.10 or later.
License in practice
Licensed under Moderne Source Available License, which is not a standard open-source license. Verify the license terms apply to your use case before adopting.
Quickstart
pip install openrewrite
from rewrite.test import RecipeSpec, python
spec = RecipeSpec(recipe=YourRecipe())
spec.rewrite_run(python("before_code", "after_code"))
Recipes run against real codebases via the Moderne CLI over an RPC bridge; there is no standalone in-process Python parser entry point.
Verify before relying
- Whether the Moderne Source Available License permits commercial use or requires a separate agreement.
- What Python versions the JVM runtime component supports when executing recipes via the Moderne CLI.
- Whether recipes authored with this package can be executed without the Moderne CLI infrastructure.
Package facts
| License | Moderne Source Available License (unclear) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — more_itertools, ty-types, parso |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 112,268/month — #12,374 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: openrewrite-8.90.0-py3-none-any.whl
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
google-pastaParse Python source code into an AST, modify…
permissive · top 1,000 on PyPI
oelint-parserParses BitBake recipe files and provides…
permissive · top 15,000 on PyPI
ropeRope is a Python refactoring library that…
copyleft · top 5,000 on PyPI
recipe-scrapersExtracts structured recipe data (ingredients,…
permissive · top 15,000 on PyPI
ordereddictProvides an OrderedDict implementation for…
permissive · top 15,000 on PyPI
flake8-plugin-utilsProvides base classes and utilities for writing…
permissive · top 5,000 on PyPI
luaparserParses Lua source code into an abstract syntax…
permissive · top 15,000 on PyPI
expecttestexpecttest implements inline golden tests where…
permissive · top 5,000 on PyPI
libcstlibcst parses Python source code into a…
permissive · top 1,000 on PyPI
tokenize-rtWraps Python's stdlib tokenize module to enable…
permissive · top 5,000 on PyPI