Skip to main content

codemod-json

This library makes surgical edits to JSON documents, based on tree-sitter and inspired by tomlkit and pyupgrade. Preserves all whitespace and formatting on lines that don't require changes, and generally within a line as well, so you can make minimal diffs in your codemod tools.

Basic Usage

{
    // some comment
    "version": ["foo"],
    "commands": [], // another comment
}
from codemod_json import parse
stream = parse(somepath.read_bytes())
if stream["version"] == ["2.7"]:
    stream["version"][:] = ["3.6", "3.13"]
somepath.write_bytes(stream.text)
{
    // some comment
    "version": ["3.6", "3.13"],
    "commands": [], // another comment
}

Version Compat

Usage of this library should work back to 3.9 (because of the tree-sitter dep), but development (and mypy compatibility) only on 3.10-3.12. Linting requires 3.12+ for full fidelity.

Versioning

This library follows meanver which basically means semver along with a promise to rename when the major version changes.

License

codemod-json is copyright Tim Hatch, and licensed under the MIT license. See the LICENSE file for details.

Metadata

Release files for codemod-json 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codemod-json 0.5.1
File Size Uploaded
codemod_json-0.5.1.tar.gz 14.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codemod-json 0.5.1
File Interpreter ABI Platform
codemod_json-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 26.9 kB

Release files / codemod_json-0.5.1.tar.gz

Download URL codemod_json-0.5.1.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c65ec3e4deb55c73a0c68f99a9625597c57a688b71aba03ca97f35c61469ed3b
BLAKE2b-256 checksum
How to use checksums
07533d2ee6d101401278a197d3535236eabd1d24106c2f447ef927b111c7c794
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2024.

Transparency log

Release files / codemod_json-0.5.1-py3-none-any.whl

Download URL codemod_json-0.5.1-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97cbadf235a445c80c8687f9f4f3a4da584073620c2bc1394514795ff9b25e9d
BLAKE2b-256 checksum
How to use checksums
d4cd1151c59d8bd573ad8ffd80e6141d6081e6c3f2ab541650a11224df43cb69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page