GitHub

API reference for yaml.

YAML text to Python values (Effect's encoding/Yaml, based on the yaml 2.9.0 package).

One document: block and flow collections, indentless sequence values, multiline plain and quoted scalars, block scalars, anchors and aliases, YAML 1.1 merge keys (an unquoted << merges a mapping or a list of mappings; explicit keys win over merged ones, earlier sources over later ones), with the YAML 1.2 core schema (null / ~, booleans, ints including 0x and 0o, floats, .inf, .nan; dates stay strings). Unlike YAML 1.2, a multiline flow collection's closing bracket may sit at its parent's indentation.

Not supported, as in Effect: compact nested block sequences (- - value), multiline quoted scalars in flow collections, explicit complex keys, tags and directives, recursive aliases, and document streams. Mapping keys are strings. Malformed or unsupported text raises ValueError.

Values

AttributeTypeDescription
MAX_INTEGER_DIGITSLiteral[1000] = 1000

The most significant digits of an integer parse reads (decimal, hexadecimal or octal); a longer one raises ValueError, as converting it costs superlinear time.

Functions

parse

parse(text) -> object

One YAML document as Python values: mappings are dict[str, ...], sequences list, scalars None, bool, int, float or str. Raises ValueError for malformed or unsupported text, and for text nested past Python's recursion limit (Effect's throws RangeError past JavaScript's stack).

ParameterTypeDescription
textstr

Returns object

def parse(text: str) -> object:
    """One YAML document as Python values: mappings are ``dict[str, ...]``,
    sequences ``list``, scalars ``None``, ``bool``, ``int``, ``float`` or
    ``str``. Raises ``ValueError`` for malformed or unsupported text, and for
    text nested past Python's recursion limit (Effect's throws ``RangeError``
    past JavaScript's stack)."""
    source = re.sub(r"\r\n?", "\n", text.removeprefix("\ufeff"))
    lines = [_make_line(raw, i) for i, raw in enumerate(source.split("\n"))]
    return parse_nested(_Parser(lines).parse)