Lib to modify yaml inplace
Project description
codemod-yaml
This library is for making targeted edits to YAML documents. The core design goal is:
- Only change lines with data changes.
While you can't edit all YAML constructs, you can generally replace them and roundtrip them thanks to tree-sitter-yaml.
This was roughly inspired by pyupgrade
which combined AST-based parsing with
more low-level edits.
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)
Supported
[x] round-tripping unedited sections verbatim [x] any valid yaml after where you're editing [x] block maps with string keys [x] block sequences [x] python str/float/list/dict
Version Compat
Usage of this library should work back to 3.7, 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file codemod_yaml-0.1.0.tar.gz
.
File metadata
- Download URL: codemod_yaml-0.1.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38bf53fd09a6f665fce84d7261fdc12dbc91a808b56ff997bc5234b1a19acaa2 |
|
MD5 | 25d2fc46d4c05e1207805c3a5af8ccf6 |
|
BLAKE2b-256 | 8c66ad60fe118650556260879ee968c8bbf7461289032702e3feba9d0472daa8 |
Provenance
The following attestation bundles were made for codemod_yaml-0.1.0.tar.gz
:
Publisher:
build.yml
on advice-animal/codemod-yaml
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
codemod_yaml-0.1.0.tar.gz
- Subject digest:
38bf53fd09a6f665fce84d7261fdc12dbc91a808b56ff997bc5234b1a19acaa2
- Sigstore transparency entry: 149594328
- Sigstore integration time:
- Predicate type:
File details
Details for the file codemod_yaml-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: codemod_yaml-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65ad4628ef95e6ca8a8feb3909c8ef709baf1e6bfd49439f76d0088ac9e717df |
|
MD5 | af296a133c8a010139abe4b75bac47f0 |
|
BLAKE2b-256 | 2ceebac9a0af2c603696e4af826cddd1e0a29d76a209daa522fc6438ebb336e9 |
Provenance
The following attestation bundles were made for codemod_yaml-0.1.0-py3-none-any.whl
:
Publisher:
build.yml
on advice-animal/codemod-yaml
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
codemod_yaml-0.1.0-py3-none-any.whl
- Subject digest:
65ad4628ef95e6ca8a8feb3909c8ef709baf1e6bfd49439f76d0088ac9e717df
- Sigstore transparency entry: 149594329
- Sigstore integration time:
- Predicate type: