Registry / serialization / ruyaml

ruyaml

JSON →
library0.91.0pypypi✓ verified 23d ago

ruyaml is a fork of ruamel.yaml, a YAML parser and emitter for Python that aims to preserve comments, order, and other structural details during round-trip loading and dumping. It is actively maintained, with version 0.91.0 being the latest stable release, and receives updates periodically, often merging upstream changes from `ruamel.yaml`.

pip install ruyaml
INSTALL
IMPORT
SIG · RUYAML
R
ruyaml
serializationpythonv0.91.0
Install
1.8s avg
Import
63ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.91.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.066s · 18.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.060s · 19MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

YAML
from ruyaml import YAML
from ruamel.yaml import YAML
Prior to version 0.20.0, the library was named `ruamel.yaml` and imported as such. `ruyaml` is a distinct fork and requires its own import path.

This quickstart demonstrates how to load and dump YAML data while preserving comments, ordering, and block/flow styles using `ruyaml`'s default `YAML()` instance for round-trip parsing.

from ruyaml import YAML from io import StringIO # Initialize a YAML instance for round-trip parsing yaml = YAML() # Example YAML data with comments and specific ordering data = """ # User Configuration name: John Doe age: 30 # Current age cities: - New York - London options: {enabled: true, max_retries: 5} """ # Load YAML data from a string stream = StringIO(data) cfg = yaml.load(stream) # Modify data - comments and structure are preserved cfg['age'] = 31 cfg['cities'].append('Paris') cfg['options']['timeout'] = 30 # Adding a new key # Dump the modified YAML data back to a string, preserving original formatting output_stream = StringIO() yaml.dump(cfg, output_stream) print(output_stream.getvalue()) # Expected output will include comments and maintain much of the original layout.
Debug
Known issues
breakingThe package was renamed from `ruamel.yaml` to `ruyaml` starting with version 0.20.0. All import paths and installation commands must reflect this change.
fix
Change `pip install ruamel.yaml` to `pip install ruyaml` and `from ruamel.yaml import ...` to `from ruyaml import ...`.
affects: 0.20.0 onwards
gotchaBy default, `ruyaml` uses a round-trip aware loader/dumper (`YAML()`) which preserves comments, ordering, and tag information. Users migrating from `PyYAML` might expect simpler type conversion or different default formatting.
fix
If simpler loading/dumping is desired, explicitly specify `typ='safe'` or `typ='unsafe'`. For example: `yaml = YAML(typ='safe')`. Be aware this will lose round-trip preservation capabilities.
affects: All versions
gotchaWhen dumping, `ruyaml` might automatically quote strings containing special characters or represent certain data structures (like dicts or lists) in block style by default, which can differ from `PyYAML`'s output or simple string representations.
fix
To control string quoting, use `yaml.indent(mapping=X, sequence=Y, offset=Z)`. To force flow style for collections, use `yaml.default_flow_style = True` or explicitly set `yaml.Representer.add_representer` for custom types. For specific string issues, `yaml.scalar_string = True` might help.
affects: All versions
Upgrade
Version history
0.91.0latest on PyPI · released Dec 7, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
ruyaml — pip install ruyaml · libregistry