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

Uploaded Python 3

File details

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

File metadata

  • Download URL: codemod_yaml-0.6.1.tar.gz
  • Upload date:
  • Size: 18.9 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.1.tar.gz
Algorithm Hash digest
SHA256 733764c2ccafe26d5a935cc79dd59e3c20fc40dc8d87a35f0d522a36ff87d632
MD5 62da7a21cf77c57eeed27f36efa2093f
BLAKE2b-256 6ed01938d88421ee13100373510ae8acde1bdd584b24ec188b47205c6c1e966a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: codemod_yaml-0.6.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e0c21874ed0bad4fa82f6b6524cec9eea4955ac04ceab5baae43c76bf3dc7fec
MD5 9e30a016e1b4f0ebc9aadcd9b1fda6b2
BLAKE2b-256 e9fff97c9d516dc77fbefb2617eb58d1c68999bb290134bb09f5be7135c22056

See more details on using hashes here.

Provenance

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