Repository navigation
Rebrand the docs around register_class, and fix four register_class bugs - #8
Merged
Merged
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, andto_yaml/from_yamlfunctions for types you do not own, with new examples for numpy'sndarray,Decimal,timedeltaandEnumplus a runnableexamples/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 newbench/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[...]; afrom_yamlhook returning a frozen dataclass crashed the load; dumping anEnumregistered with hooks raisedTypeError; and a%YAML 1.1document read0755as 755 instead of the octal 493. Also adds crates.io READMEs and metadata for both crates, and commitsuv.lock.