Skip to main content

astral-yaml for Python

astral_yaml reads and writes YAML 1.2 on CPython 3.11 and newer.

Reading YAML

The loader uses the YAML 1.2 core schema. In this configuration, the port numbers become Python integers and the unquoted word on stays a string.

import astral_yaml as yaml

config = yaml.loads("ports: [80, 443]\nmode: on")
assert config == {"ports": [80, 443], "mode": "on"}

load and loads accept at most one document per call. Empty or comment-only input returns None. A second document raises yaml.YAMLError.

Use load_all for an open text or binary file and loads_all for a string or encoded bytes. Both return a list in document order. An empty or comment-only stream gives [], and an explicit empty document contributes None. An error in any document raises during the call.

configs = yaml.loads_all("---\nmode: on\n---\nports: [80, 443]\n")
assert configs == [{"mode": "on"}, {"ports": [80, 443]}]

Mapping keys must be scalars and must stay unique when converted to Python. For example, {true: first, 1: second} raises yaml.YAMLError because True == 1 in Python.

Writing YAML

dumps returns YAML as a string, and dump writes it to a text stream. Both use block style by default, with two spaces per indentation level. Pass style="flow" for collections written with brackets and braces. Block mappings use plain string keys when their spelling and type are unambiguous. String values and flow-style string keys use double quotes. Empty collections use [] or {} in either style.

config["ports"].append(8080)
assert yaml.dumps(config) == 'ports:\n  - 80\n  - 443\n  - 8080\nmode: "on"\n'
assert yaml.dumps(config, style="flow") == '{"ports": [80, 443, 8080], "mode": "on"}\n'

with open("config.yaml", "w", encoding="utf-8") as file:
    yaml.dump(config, file)

# In binary mode, load detects UTF-8, UTF-16, or UTF-32.
with open("config.yaml", "rb") as file:
    assert yaml.load(file) == config

Tuples serialize as sequences and load back as lists. If two dictionary entries share a list, the dumper uses a YAML alias so the entries still share a list when you read them back. Aliases also preserve cycles.

Errors

  • YAML errors. Invalid YAML, unsupported tags, and resource limits (including Python's digit limit for decimal integers) raise yaml.YAMLError. Parse errors report byte offsets in the original encoding for binary input and in UTF-8 for text.
  • Unsupported Python values. The dumper accepts None and exact instances of bool, int, float, str, list, tuple, and dict. Other types raise TypeError.
  • I/O errors. Exceptions from the file's read or write method propagate to the caller.

Metadata

Release files for astral-yaml 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for astral-yaml 0.0.7
File Size Uploaded Provenance Actions
astral_yaml-0.0.7.tar.gz 899.8 kB With provenance Details for astral_yaml-0.0.7.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for astral-yaml 0.0.7
File Actions
astral_yaml-0.0.7-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details for astral_yaml-0.0.7-cp311-abi3-win_arm64.whl
astral_yaml-0.0.7-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for astral_yaml-0.0.7-cp311-abi3-win_amd64.whl
astral_yaml-0.0.7-cp311-abi3-manylinux_2_34_x86_64.whl CPython 3.11 abi3 Linux glibc 2.34+ x86-64 Details for astral_yaml-0.0.7-cp311-abi3-manylinux_2_34_x86_64.whl
astral_yaml-0.0.7-cp311-abi3-manylinux_2_34_aarch64.whl CPython 3.11 abi3 Linux glibc 2.34+ ARM64 Details for astral_yaml-0.0.7-cp311-abi3-manylinux_2_34_aarch64.whl
astral_yaml-0.0.7-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for astral_yaml-0.0.7-cp311-abi3-macosx_11_0_arm64.whl
astral_yaml-0.0.7-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for astral_yaml-0.0.7-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 3.0 MB

Release files / astral_yaml-0.0.7.tar.gz

Download URL astral_yaml-0.0.7.tar.gz
Size 899.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c13bd29f061b428ad643b4fc03d035adc94ea616bdf7e52097972ed1a685df7b
BLAKE2b-256 checksum
How to use checksums
1c2d274204fe20ef675a3d47759b3550e43fa5d819fe0a68b3c527efbb769b40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / astral_yaml-0.0.7-cp311-abi3-win_arm64.whl

Download URL astral_yaml-0.0.7-cp311-abi3-win_arm64.whl
Size 277.4 kB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
7977d3546e0e12eddcc89ea436865ef6527306f02112123257f3df7d7d8e4487
BLAKE2b-256 checksum
How to use checksums
f819e0a14802dd3901dde401ce295b01f7f1c7ea6fe1467ca0fcfbefd2966cdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / astral_yaml-0.0.7-cp311-abi3-win_amd64.whl

Download URL astral_yaml-0.0.7-cp311-abi3-win_amd64.whl
Size 287.9 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
49731b8bbfd06bb7cf89bfe48c07ea43b48a3b2c3925329feff53187ebc02168
BLAKE2b-256 checksum
How to use checksums
7b4d03ec3239f86ce9e8c0eb2216618dbab7c4233ac5e1de5ac1246a845e5dfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / astral_yaml-0.0.7-cp311-abi3-manylinux_2_34_x86_64.whl

Download URL astral_yaml-0.0.7-cp311-abi3-manylinux_2_34_x86_64.whl
Size 407.7 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
9effd4a4b2e7c5fc5ea0888d0954d1ee7e80ea726e9ae3c2d9de8000f495fa66
BLAKE2b-256 checksum
How to use checksums
2810b32bd9c984671624648ca5966d91befd41535dbe3a43e0fd5a0920437afd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / astral_yaml-0.0.7-cp311-abi3-manylinux_2_34_aarch64.whl

Download URL astral_yaml-0.0.7-cp311-abi3-manylinux_2_34_aarch64.whl
Size 407.7 kB
Tags CPython 3.11 Linux glibc 2.34+ ARM64 abi3
SHA-256 checksum
How to use checksums
3113f81355f01fa58ff08680ae0d7987290838b6760b76d0c2ea461be33f69c3
BLAKE2b-256 checksum
How to use checksums
d00acfdabef8ca24303d3a0536bc872349e04950b8f42ab3c13c3eea6d8e236b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / astral_yaml-0.0.7-cp311-abi3-macosx_11_0_arm64.whl

Download URL astral_yaml-0.0.7-cp311-abi3-macosx_11_0_arm64.whl
Size 379.2 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5909bc6d891e8249cfe6e0caa71efd80ba2234cd57cba5d1786f1d546407916e
BLAKE2b-256 checksum
How to use checksums
abf79e890bd0b8388a7ce8d59f4a874ad16ba4c74c69794f3e1c658d7dcadffd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / astral_yaml-0.0.7-cp311-abi3-macosx_10_12_x86_64.whl

Download URL astral_yaml-0.0.7-cp311-abi3-macosx_10_12_x86_64.whl
Size 383.7 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
50f0603ae5a00c426b0352c37e16a2de9379a6feae40206f4c72c626b5f5f324
BLAKE2b-256 checksum
How to use checksums
9c49f966f949eba19363d406d96e04435be8e41f58aa5f297acfb1597aa210b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for astral-yaml 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for astral_yaml-0.0.7.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page