Skip to main content

Lib to modify yaml inplace

Project description

codemod-yaml

This library makes surgical edits to YAML 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

from codemod_yaml import parse
stream = parse(somepath.read_bytes())
if stream["version"] == ["2.7"]:
    stream["version"][:] = ["3.6", "3.13"]
somepath.write_bytes(stream.text)

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-yaml is copyright Tim Hatch, and licensed under the MIT license. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codemod_yaml-0.5.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

codemod_yaml-0.5.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file codemod_yaml-0.5.0.tar.gz.

File metadata

  • Download URL: codemod_yaml-0.5.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for codemod_yaml-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d01a1c02561eb98db6dff03e4918bbde15663a095d4304a947bac05c75323087
MD5 8022aea4cbae35f6acfda61ba695a31f
BLAKE2b-256 37dbb8a6a0f77582ad7dafc29b2b30ea2699ca7fa85f2df9d7f5b58cce6512d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for codemod_yaml-0.5.0.tar.gz:

Publisher: build.yml on advice-animal/codemod-yaml

Attestations:

File details

Details for the file codemod_yaml-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: codemod_yaml-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for codemod_yaml-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5de5f462958254a3208096e701173a259a8dfd916f22177c4dff2725f74ab2a
MD5 d38637349040f1ee2d88c58fc00f521b
BLAKE2b-256 9dd1120953afd72ae7a5374a612daaede0bbb879f8021ec34c175c5ecdb41fc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for codemod_yaml-0.5.0-py3-none-any.whl:

Publisher: build.yml on advice-animal/codemod-yaml

Attestations:

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