Skip to main content

A pluggable framework for building codemods in Python

Project description

Pixee Logo

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
Base Codemod Diagram

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

codemodder-3.7.0.tar.gz (703.2 kB view details)

Uploaded Source

Built Distribution

codemodder-3.7.0-py3-none-any.whl (286.3 kB view details)

Uploaded Python 3

File details

Details for the file codemodder-3.7.0.tar.gz.

File metadata

  • Download URL: codemodder-3.7.0.tar.gz
  • Upload date:
  • Size: 703.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for codemodder-3.7.0.tar.gz
Algorithm Hash digest
SHA256 ceac8667e04461b58f08bd0691e98a9dad642a43ecac6ee25b8599a5d8e9a3f7
MD5 8c664b63070ad2440259bb2299f163d0
BLAKE2b-256 1fc4117a4f09744a4f66c6b38d8b5991b9a9685b08540a1436233bc722705a4a

See more details on using hashes here.

File details

Details for the file codemodder-3.7.0-py3-none-any.whl.

File metadata

  • Download URL: codemodder-3.7.0-py3-none-any.whl
  • Upload date:
  • Size: 286.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for codemodder-3.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7b7fd23865072263aaec23015b319e42fc96157ff0e7e0bd261c06c013db23c
MD5 37fcb3a240a8b5fc45d51a4f83d957bf
BLAKE2b-256 d8d1d3fba89097b91d4b0f69883a9223f267ff40e1eca76e0612fd4c6a56faf3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page