msgspec-yaml
Simple YAML loader for msgspec.Struct.
Installation
uv
uv add msgspec-yaml
pip
pip install msgspec-yaml
poetry
poetry add msgspec-yaml
Usage
import msgspec
import msgspec_yaml
class Config(msgspec.Struct):
host: str
port: int
config = msgspec_yaml.load("config.yml", Config)
print(config.host)
print(config.port)
Example YAML file:
host: localhost
port: 8000
API
msgspec_yaml.load(path, struct, encoding="utf-8")
Load a YAML file and convert its contents into a msgspec.Struct.
Parameters
path(str | pathlib.Path) — path to the YAML file.struct(type[msgspec.Struct]) — target structure class.encoding(str) — file encoding. Defaults toutf-8.
Returns
An instance of the provided msgspec.Struct.
Raises
FileNotFoundError— file does not exist.yaml.YAMLError— invalid YAML file or unsupported file extension.msgspec.ValidationError— data validation failed during conversion.
Why?
Instead of writing:
import msgspec
import yaml
class Config:
host: str
port: int
with open("config.yml") as f:
data = yaml.safe_load(f)
config = msgspec.convert(data, type=Config)
you can simply write:
import msgspec_yaml
class Config:
host: str
port: int
config = msgspec_yaml.load("config.yml", Config)
Metadata
Release files for msgspec-yaml 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| msgspec_yaml-1.0.2.tar.gz | 1.6 kB | Without provenance | Details for msgspec_yaml-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| msgspec_yaml-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for msgspec_yaml-1.0.2-py3-none-any.whl |
Total release size: 4.1 kB
Release files / msgspec_yaml-1.0.2.tar.gz
| Download URL | msgspec_yaml-1.0.2.tar.gz |
|---|---|
| Size | 1.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fec139b7ee2f64e13b044a77b7f521f718d37ddb4e4e3b743a6a3096b04f997b
|
|
BLAKE2b-256 checksum How to use checksums |
7b63ebc4307f0a190291e057e2d86efbea26af940bf687b92b3773d10f75dc0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / msgspec_yaml-1.0.2-py3-none-any.whl
| Download URL | msgspec_yaml-1.0.2-py3-none-any.whl |
|---|---|
| Size | 2.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ee4de313e8d140a12c916fa87f68ea4be8eba7de9a5b4cf858b5ceacf5733e5
|
|
BLAKE2b-256 checksum How to use checksums |
dc1bc31885f280301fc99dda411d1a1b99860f0f72c5f864d7aa013a2a9afa60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for msgspec-yaml 1.0.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.