Skip to main content

A YAML round-trip library that preserves comments and insertion order

Project description

yarutsk

PyPI Python 3.12+ License: MIT

⚠ AI-authored. This library — design, implementation, tests, and documentation — was written by Claude Code (Anthropic) under human direction.

A Python YAML library that round-trips documents while preserving comments, insertion order, scalar styles, tags, anchors and aliases, blank lines, and explicit document markers.

Full documentation: https://theyugin.github.io/yarutsk/

Quick start

pip install yarutsk
import io
import yarutsk

doc = yarutsk.load(io.StringIO("""
# database config
host: localhost  # primary
port: 5432
"""))

doc["port"] = 5433

out = io.StringIO()
yarutsk.dump(doc, out)
print(out.getvalue())
# # database config
# host: localhost  # primary
# port: 5433

YamlMapping and YamlSequence implement the dict/list protocols (subscript, iteration, len, in, etc.) but are not dict/list subclasses. Call doc.to_python() (recursive) for a plain dict/list — needed for json.dumps, pydantic, msgspec, cattrs, and other libraries that type-check input strictly.

Python 3.12+ required. Pre-built wheels for Linux / macOS / Windows on x86_64 and aarch64.

What's preserved

  • Scalar styles — plain, 'single', "double", literal |, folded >
  • Non-canonical scalarsyes/no/on/off, ~, 0xFF, 0o77 reproduced as written
  • YAML tags!!str, !!binary, !!timestamp, and any custom tag
  • Anchors and aliases&name / *name round-trip intact
  • Blank lines between entries and explicit document markers (---, ...)

Comparison

Feature yarutsk ruamel.yaml PyYAML
Comments preserved Yes Yes No
Scalar styles preserved Yes Partial No
Insertion order preserved Yes Yes No
Blank lines preserved Yes Partial No
Tags preserved Yes Yes No
Anchors/aliases preserved Yes Yes No
Rust speed Yes No No

yarutsk focuses on round-trip fidelity: edit a config file and emit it back without touching the formatting. ruamel.yaml offers similar fidelity in pure Python. PyYAML is faster for load-only workloads where output formatting doesn't matter.

Documentation

Everything — the full API, type conversions, Schema and library integrations (pydantic / msgspec / cattrs), error handling, thread safety, and limitations — lives at https://theyugin.github.io/yarutsk/.

Direct links:

Benchmarks

Compare load, dump, and round-trip performance against PyYAML and ruamel.yaml:

make bench

License

MIT. The scanner and parser are vendored from yaml-rust2 (also MIT) with one targeted modification: the comment-skipping loop now emits Comment tokens instead of discarding them.

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

yarutsk-0.8.2.tar.gz (248.8 kB view details)

Uploaded Source

Built Distributions

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

yarutsk-0.8.2-cp314-cp314-win_amd64.whl (559.8 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.8.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (678.9 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.8.2-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.3 MB view details)

Uploaded CPython 3.14macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

yarutsk-0.8.2-cp313-cp313-win_amd64.whl (565.4 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.8.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (685.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.8.2-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.3 MB view details)

Uploaded CPython 3.13macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

yarutsk-0.8.2-cp312-cp312-win_amd64.whl (565.7 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (686.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.8.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.3 MB view details)

Uploaded CPython 3.12macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file yarutsk-0.8.2.tar.gz.

File metadata

  • Download URL: yarutsk-0.8.2.tar.gz
  • Upload date:
  • Size: 248.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yarutsk-0.8.2.tar.gz
Algorithm Hash digest
SHA256 4ffe72bc59ea60aee165ff7e622f410e9650a4d89d9dac2eacac63c0acbf4417
MD5 be4a1eabf1717e40dadddb2ee30fcb82
BLAKE2b-256 4611a08df2fde7138b16408f3f2e07ad2519a2250747262307ba0e7227a417f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.2.tar.gz:

Publisher: ci.yml on theyugin/yarutsk

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

File details

Details for the file yarutsk-0.8.2-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: yarutsk-0.8.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 559.8 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yarutsk-0.8.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 715e825ecba862d7620c39d5aff1cd6d2b69d860b560846ea11279550bda5f34
MD5 5297ba71b4ea69a693226eb24c2644b5
BLAKE2b-256 b4f32ce4c5255cd572ec40a4b39ec8f75495584cd45cf187dec2210fdc87f8de

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.2-cp314-cp314-win_amd64.whl:

Publisher: ci.yml on theyugin/yarutsk

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

File details

Details for the file yarutsk-0.8.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for yarutsk-0.8.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d322ced28afc3f70e81b60e9bc19d7c5ee87a14f446073ad4971a77474631afd
MD5 560e21ffc49a32db201b7896eac4009b
BLAKE2b-256 452e3a99618eba20e92c4b8887f1dc391e34379cb6aaf1144a8225e9df86d61f

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci.yml on theyugin/yarutsk

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

File details

Details for the file yarutsk-0.8.2-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for yarutsk-0.8.2-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 e3e21626337dd8dc2f35c734ec838da9231f778a57bae8cdff3fceb6dd876e82
MD5 a1a0513e36f9424689fafd4d0541dc12
BLAKE2b-256 53115ba6c9dcd87b7790c555fbafcb0637cd3b43a72877d4525e769ca1fb3d80

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.2-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: ci.yml on theyugin/yarutsk

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

File details

Details for the file yarutsk-0.8.2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: yarutsk-0.8.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 565.4 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yarutsk-0.8.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 5cb6490f5deec5339a65064ea2fe96b63c6d0da71713fb89070e91a390201358
MD5 82e616b4ac79043255dd7a31010829ed
BLAKE2b-256 74f25352531fe47a3861ca0046b6f18d45d70c5df592110d2d87c2a525994dd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.2-cp313-cp313-win_amd64.whl:

Publisher: ci.yml on theyugin/yarutsk

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

File details

Details for the file yarutsk-0.8.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for yarutsk-0.8.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b9406d99b5ee7ee05edbe864baee314d5fdf8ab2537148c721870c537e5a3665
MD5 47bad7722ce6c10a83ad544564b4f329
BLAKE2b-256 0904a2656b3a22eb7ed60b934a8a40baf676467f5784482077a3138beb8f489d

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci.yml on theyugin/yarutsk

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

File details

Details for the file yarutsk-0.8.2-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for yarutsk-0.8.2-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 672601ce00a1e49d80923ab5cbbd8b7025010e6c52b83f163d48fed1e3f86780
MD5 628290fd8cbb76c971f03378f73d0071
BLAKE2b-256 fe19b23f822f2cf48d456cc5e95fdc194047bac7179358bad105c87c12764b09

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.2-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: ci.yml on theyugin/yarutsk

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

File details

Details for the file yarutsk-0.8.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: yarutsk-0.8.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 565.7 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yarutsk-0.8.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 dd54794401277f8c9a65a7edf4c5061368a35baf7880d87d625607491fcdc561
MD5 75fda0544f85cf849b35ba108dcf4eec
BLAKE2b-256 9de4e9df6c2a7bff6c16f54eb3d10c4b42a7e0304d0c050e8941deabed3978dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.2-cp312-cp312-win_amd64.whl:

Publisher: ci.yml on theyugin/yarutsk

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

File details

Details for the file yarutsk-0.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for yarutsk-0.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4060af206b1c41ab48932068be061bf7dc6ff391663790e4601c86cb5d3af39f
MD5 7c85e71105a9ee28f40efbaa0cafd9d9
BLAKE2b-256 840f19a95988c4a6b46f701075bcd2b7fd3350cfecce592c11146efc2e3a087e

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci.yml on theyugin/yarutsk

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

File details

Details for the file yarutsk-0.8.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for yarutsk-0.8.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 21658c6257db618d35113fa102d7b5500d1b49f2903ab5c90444f3bec5cb61d0
MD5 efe739dc200a2ec56624bc059d931d0e
BLAKE2b-256 bef3408483f3b6dbb5f14d9fca9dc2aa36351e64fe56a03a71d68e69f4d71b46

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: ci.yml on theyugin/yarutsk

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