yaml
yaml
¶
Centralised YAML I/O — round-trip mode everywhere.
Facade over ruamel.yaml's ceremony-heavy YAML() class: callers get
a minimal load / dump / YAMLError surface instead of instance
creation, typ selection, stream management, and config attributes.
Adapter from ruamel.yaml's stream-oriented API to the string-based
convention used throughout the ecosystem (path.read_text() → load(text)
→ modify → dump(data) → path.write_text(text)).
CommentedMap is a dict subclass — isinstance(x, dict), .get(),
x["key"], .setdefault() all work transparently. Pydantic v2
model_validate() accepts dict subclasses, so read-side validation is
unchanged.
__all__ = ['load', 'dump', 'YAMLError']
module-attribute
¶
load(text)
¶
dump(data, *, default_flow_style=False)
¶
Round-trip dump to a YAML string, preserving comments and order.
Key order is preserved (insertion order for new dicts, original order for
round-tripped data). sort_keys is always False — the caller never
needs to pass it.