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.8.0rc1.tar.gz (23.8 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.8.0rc1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file codemod_yaml-0.8.0rc1.tar.gz.

File metadata

  • Download URL: codemod_yaml-0.8.0rc1.tar.gz
  • Upload date:
  • Size: 23.8 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.8.0rc1.tar.gz
Algorithm Hash digest
SHA256 93ed78b94908538ab02e4e0f9b4fac9aa64bd6df2d934da6d2398fed60cdfa95
MD5 6f72beaa12dace5ef070fd4766ff7496
BLAKE2b-256 58fa1e3f1e7e215bf25e5c9216c04a3782aa387c4486fd593cc9ea345efa247b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codemod_yaml-0.8.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 d53b376450b173d8987945ff6527fd549dacf8345480e087822f0e05a1f20687
MD5 fa7d0930fbb75cb0d8a6d318d4427a8f
BLAKE2b-256 02be5e63fffaaa01be524c596c4f9b9a778372c066180c8d893b9ecbae075b29

See more details on using hashes here.

Provenance

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