jcrist · GitHub

@jcrist

This adds a new `msgspec.yaml` submodule for encoding/decoding YAML
messages using the type system provided by msgspec. This can be useful
for configuration files, or for validating YAML before encoding it in
some other format. For example, in a past job I could have used this to
load and validate k8s manifests from YAML, before processing and sending
them to the k8s server as JSON.
This relies on the third-party PyYAML library for YAML support. A `yaml`
extra has been added for providing this dependency.
For now only `encode` and `decode` functions have been provided; no
`Encoder`/`Decoder` types. The builtin `msgpack`/`json` integration can
benefit from reusing those objects, but the overhead of PyYAML and the
type conversations makes the use of such types useless beyond interface
compatibility. We can add them later if a user need arises.

Read the original on github.com ↗