A pluggable framework for building codemods in Python
Project description
codemodder-python
This is the Python version of the Codemodder Framework.
Codemodder is sponsored by pixee.ai.
Development Status
As of v0.80.0 the codemod API is relatively stable. However, backwards compatibility between releases will not be guaranteed until version 1.0.0.
See CHANGELOG.md for detailed release notes.
Installation
The codemodder
package is available on PyPI. To install, run:
$ pip install codemodder
To install the package from source, use pip
:
$ pip install /path/to/codemodder-python
Running codemodder
CLI
Codemodder can be run as a CLI. The codemodder package provides an executable called codemodder
. This should be available on your path by default after installation.
For basic usage, run the codemodder
command with a target directory path:
$ codemodder /path/to/my-project
Note that by default codemodder
will make changes to files in your target directory. To run codemodder
without making updates on disk, use the --dry-run
flag:
$ codemodder --dry-run /path/to/my-project
To list all available codemods (including any that are registered with installed plugins), use the --list
option:
$ codemodder --list
For a full list of options, use the --help
flag:
$ codemodder --help
Library
You can also run codemodder
as a library by importing the module and running run
. For basic usage, pass a target directory path and the dry_run
argument:
import codemodder
output, exit_code = codemodder.run("/path/to/my-project", dry_run=True)
Unlike the CLI which has a default dry_run
of False
, when calling codemodder
as a library you must indicate if you want codemodder
to make changes to your files.
Architecture
Codemods are composed of the following key components:
- Detector
- Transformer(s)
- Metadata
Custom Codemods
The Python codemodder supports a plugin infrastructure for custom codemods. For users interested in developing a custom codemod plugin, we recommend starting with the Cookiecutter template.
Documentation
Coming soon!
Contributing
See CONTRIBUTING.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file codemodder-3.10.0.tar.gz
.
File metadata
- Download URL: codemodder-3.10.0.tar.gz
- Upload date:
- Size: 737.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b64770d385f0ea6cfac1872058e73253199ec8cbbf70140197217b6d307c86eb |
|
MD5 | 76fe228a56fd153067f9aca9a7236671 |
|
BLAKE2b-256 | 24c1ecedad5dc7724c5d844b5d0ce49d61cc54acaa759bf3454e7cf46e0275c5 |
File details
Details for the file codemodder-3.10.0-py3-none-any.whl
.
File metadata
- Download URL: codemodder-3.10.0-py3-none-any.whl
- Upload date:
- Size: 286.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0ca3b5cba074a4e98662d59068a62bdd55bb9c568e9e351aa19121d9d5adb39 |
|
MD5 | 3940959269488b75c150091210c29cd7 |
|
BLAKE2b-256 | 13ec0c5e9bc7a26d53ae50c5303094a93fd078f802f8c2be966f275c5b67e25a |