Skip to content

Rebrand the docs around register_class, and fix four register_class bugs - #8

Merged
fedonman merged 11 commits into
mainfrom
improve-documentation
Sep 28, 2026
Merged

fedonman merged 11 commits into
mainfrom
improve-documentation

Conversation

@fedonman

@fedonman fedonman commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Rebrands yamluna as "YAML for Python, out of the box" across the README, the docs site, the PyPI metadata and the repo description, and leads the docs with register_class: the decorator for your own classes, and to_yaml/from_yaml functions for types you do not own, with new examples for numpy's ndarray, Decimal, timedelta and Enum plus a runnable examples/register_class.py (numpy joins the dev dependencies so CI can run it). The comparison and migration pages now cover PyYAML, ruamel.yaml, py-yaml12 and StrictYAML rather than ruamel.yaml alone, with a feature table, round-trip and speed results reproduced by the new bench/libraries.py, and migration guides from each library. The site nav is now Get started, User guide, API reference and Changelog. Writing those examples turned up five bugs, fixed here with regression tests: registered objects in a list were written as - !Server host: a, which does not reload; a block collection inside a flow one was written with - items inside [...]; a from_yaml hook returning a frozen dataclass crashed the load; dumping an Enum registered with hooks raised TypeError; and a %YAML 1.1 document read 0755 as 755 instead of the octal 493. Also adds crates.io READMEs and metadata for both crates, and commits uv.lock.

Port saphyr#129: an empty node is now an empty plain scalar instead
of "~", so the yaml-test-suite runner no longer rewrites "=VAL :".
Bump the saphyr dev-dependency to 0.1.0 and drop the loader's "~"
special case for synthetic empty nodes.
Rebrand the README, the site and the package metadata around what
yamluna does by default rather than around comments alone, and lead
with register_class: the decorator for your own classes, and to_yaml /
from_yaml functions for types you do not own, such as numpy's ndarray,
Decimal, timedelta and Enum.

The site nav is now Get started, User guide, API reference and
Changelog. examples/register_class.py is new and CI runs it, so numpy
joins the dev dependencies.
- A tagged or anchored block collection after `-` or `?` put its
  first child on the same line, so a list of registered objects was
  written as `- !Server host: a`, which tags the key and does not
  reload.
- A block collection inside a flow one was written block, with `-`
  items inside `[...]`. Everything inside `[]` or `{}` is now flow.
- A from_yaml hook returning a frozen dataclass crashed the load when
  the loader parked its node record on the object. The parent now
  keeps the record instead, as it does for a bare str.
- Dumping an Enum registered with hooks raised TypeError: the shared
  object scan reached the class through `__objclass__` and called its
  unbound `__getstate__`. A class has no state to walk.
@fedonman fedonman changed the title Add crate READMEs and crates.io metadata Rebrand the docs around register_class, and fix four register_class bugs Sep 28, 2026
The comparison page now measures PyYAML, py-yaml12 and StrictYAML
alongside ruamel.yaml: a feature table, the round-trip corpus, and
load-and-save times, all reproduced by the new bench/libraries.py
(its dependencies are the new `bench` group). The timings say plainly
that PyYAML with libyaml and py-yaml12 are faster, and why.

Migrating gains an overview and guides from PyYAML (and oyaml) and
from py-yaml12 and StrictYAML; the ruamel.yaml guide moves to
migrating/ruamel.md.
Under an explicit %YAML 1.1, a leading 0 followed by octal digits is
an octal number, as PyYAML and the 1.1 spec read it: 0755 is 493. It
loads as a Yaml11OctalInt, an OctalInt that writes itself back with
the leading 0, so an unedited file round-trips and an edited value
keeps its spelling. This covers plain scalars, a bare root scalar and
an explicit !!int. YAML 1.2 documents still read 0755 as 755.
@fedonman
fedonman merged commit 8f1d5cb into main Sep 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant