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. Empty collections use [] or {} in either style.

config["ports"].append(8080)
assert yaml.dumps(config) == '"ports":\n  - 80\n  - 443\n  - 8080\n"mode": "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.6

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.6
File Size Uploaded Provenance Actions
astral_yaml-0.0.6.tar.gz 892.8 kB With provenance Details for astral_yaml-0.0.6.tar.gz

Built distributions (wheels)

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

Total release size: 3.0 MB

Release files / astral_yaml-0.0.6.tar.gz

Download URL astral_yaml-0.0.6.tar.gz
Size 892.8 kB
Tags Source
SHA-256 checksum
How to use checksums
12623c1a9241f0053b8d7bb22a3ba52a2bf0cd77380282460a5c9161994491b8
BLAKE2b-256 checksum
How to use checksums
d1c8ebb0f013c68115d6de72e6ca19025134bc2c683cfaef13df55aa96e77213
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 20, 2026.

Transparency log

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

Download URL astral_yaml-0.0.6-cp311-abi3-win_arm64.whl
Size 263.8 kB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
528303a20a3c2a5617dbcf690503bf54f16ff9417f33d2f8ef655da1f6df2e98
BLAKE2b-256 checksum
How to use checksums
9e9478d61b93bfe9cf1780f412e09b81cdcefe3f8850239b67e7fb08218dd50c
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 20, 2026.

Transparency log

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

Download URL astral_yaml-0.0.6-cp311-abi3-win_amd64.whl
Size 278.0 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
aaf8b8e3e4e4d7babd310d93dcdc63e4b4340aa91e113572017aaa136e32a78b
BLAKE2b-256 checksum
How to use checksums
1ec2ed82716ec3adc1536de88cf5b38b5b86b59523d315671b5183ba0947badf
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 20, 2026.

Transparency log

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

Download URL astral_yaml-0.0.6-cp311-abi3-manylinux_2_34_x86_64.whl
Size 392.3 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
074e22bcc347db3d307f41a3777232c978a9afacc3bb59f0354b9f0a06104a70
BLAKE2b-256 checksum
How to use checksums
43c9222cc43305a0101932f81a99c52ba3c7e7ecae618a70d8dda17ceea6af04
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 20, 2026.

Transparency log

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

Download URL astral_yaml-0.0.6-cp311-abi3-manylinux_2_34_aarch64.whl
Size 395.5 kB
Tags CPython 3.11 Linux glibc 2.34+ ARM64 abi3
SHA-256 checksum
How to use checksums
dd4eeab3416be54a922e9fc6ed03e9efe9dbaeec82f7e4fce1f6f086e6259b23
BLAKE2b-256 checksum
How to use checksums
af8fa747a2332bb440a3e2ce6c7ea6ba444ef6cfe6472dae8e0533ca0f26747d
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 20, 2026.

Transparency log

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

Download URL astral_yaml-0.0.6-cp311-abi3-macosx_11_0_arm64.whl
Size 371.6 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
236ffd387052350f0c4604c510337a8916d11bf358040b8bf14c03d24bc58ed2
BLAKE2b-256 checksum
How to use checksums
064c6009cd48555c4c4ea56673eb588e659074efb1ff06d2260da459e38cef6a
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 20, 2026.

Transparency log

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

Download URL astral_yaml-0.0.6-cp311-abi3-macosx_10_12_x86_64.whl
Size 376.2 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
20f118a6c05b410e4cbebf001ac32f39cd57ce5021425fcbba0607319f979c44
BLAKE2b-256 checksum
How to use checksums
9d6e7b5b8a55b1ebe23e46fcf7b40eaaeba247611ec1738f0cd9d3428f8ae15c
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 20, 2026.

Transparency log

Security for astral-yaml 0.0.6

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.6.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 20, 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