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.6.2.tar.gz (19.0 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.6.2-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codemod_yaml-0.6.2.tar.gz
  • Upload date:
  • Size: 19.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.6.2.tar.gz
Algorithm Hash digest
SHA256 331cfe7db67f61abfa5d2b4c374ade8fb88929e587fa8324f29784baccc4d6bd
MD5 3e6f0f144e7842bd02dd9cd4b2a17a17
BLAKE2b-256 80e9ec2b36b518b9ca1be17cff40c089afeb483ef179f4ca6d465b8b869d9112

See more details on using hashes here.

Provenance

The following attestation bundles were made for codemod_yaml-0.6.2.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.6.2-py3-none-any.whl.

File metadata

  • Download URL: codemod_yaml-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 13.7 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.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff2d9a3f443540d967c160294de257a917889a9fe0c918f96d2370c5b4e4524f
MD5 1d9548ba5ef5d1d8b8391c0e6d043be9
BLAKE2b-256 e6da8d923924ed9b597fa86c59a00ecd4aed8950467c00cd13113d3bc63a5f20

See more details on using hashes here.

Provenance

The following attestation bundles were made for codemod_yaml-0.6.2-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