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.7.0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codemod_yaml-0.7.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codemod_yaml-0.7.0.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for codemod_yaml-0.7.0.tar.gz
Algorithm Hash digest
SHA256 1a1c7042831002b3f2355d10a1cc3fce9aeef9a9a4c6ce8af49aaef7f436b0b5
MD5 5c7d69d4f92b214f31212e59f74fcd1b
BLAKE2b-256 f4db4ddb84b51960ee5dbb74fc455cf6039e84e04f6a4de1f7e77ee33d16b32e

See more details on using hashes here.

Provenance

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

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: codemod_yaml-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for codemod_yaml-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f989076eaa109412391054ab3594170592d3be62006ede24e3604248b30df327
MD5 719b245cdbbc2eb2fb11b181732b953d
BLAKE2b-256 7a910bd030ded6d5721730f0409c81ba59bc7e69e0162f0a282184418ce6f149

See more details on using hashes here.

Provenance

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

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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