msgspex
A collection of msgspec extensions: custom types, cast helpers, decode hooks, encode hooks and deprecation system.
Quick Start
import msgspex
from msgspex.custom_types import Email, datetime
value = msgspex.decoder.decode('"user@example.com"', type=Email)
dt = msgspex.decoder.decode('"2024-01-02T03:04:05Z"', type=datetime)
payload = msgspex.encoder.encode(dt)
Installing
pip install msgspex
uv add msgspex
poetry add msgspex
After import msgspex, all hooks and types are registered automatically.
Custom Types
1. Types from kungfu
Option[T]— optional value type based onkungfu(Some | Nothing | msgspec.UnsetType).
There is also decode-hook integration for kungfu.Sum (not a custom type, but supported by the decoder).
2. Types Derived from stdlib
date— re-export ofdatetime.date.datetime— meta-type that coversStringTimestampDatetime(alias:stimestamp),IntTimestampDatetime(alias:itimestamp),FloatTimestampDatetime(alias:ftimestamp),ISODatetime(alias:isodatetime), anddatetime.datetime.timedelta— subclass ofdatetime.timedeltawith cast support.StrEnum,BytesEnum,IntEnum,FloatEnum,EnumandEnumMeta—enumextensions for stable handling of unknown values.Literal— runtime type conceptually compatible withtyping.Literal.dataclasses.InitVar— Passing vars to a__post_init__method.
3. OpenAPI-Oriented Types
Email—format: emailIDNEmail—format: idn-emailURI—format: uriURIReference—format: uri-referenceIRI—format: iriIRIReference—format: iri-referenceHostname—format: hostnameIDNHostname—format: idn-hostnameIPv4—format: ipv4IPv6—format: ipv6JsonPointer—format: json-pointerRelativeJsonPointer—format: relative-json-pointerRegex—format: regexInt32,Int64— range-limited integer typesFloat32,Float64— finite, range-limited floating-point typesUUID4— uuid v4
UUID, Decimal, date and time already supported by msgspec.
License
msgspex is MIT licensed
Metadata
Release files for msgspex 1.8.0
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 |
|---|---|---|---|---|
| msgspex-1.8.0.tar.gz | 31.9 kB | Without provenance | Details for msgspex-1.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| msgspex-1.8.0-py3-none-any.whl | Python 3 | none | any | Details for msgspex-1.8.0-py3-none-any.whl |
Total release size: 78.2 kB
Release files / msgspex-1.8.0.tar.gz
| Download URL | msgspex-1.8.0.tar.gz |
|---|---|
| Size | 31.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db415bac2226e0264c32f5f2c969a432c9deff748731eecee311a53aefe52635
|
|
BLAKE2b-256 checksum How to use checksums |
6b980fc02b2120536b393e5d0494b491709d4084ca35d446b82a5ab7993a3adb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / msgspex-1.8.0-py3-none-any.whl
| Download URL | msgspex-1.8.0-py3-none-any.whl |
|---|---|
| Size | 46.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
232bb161355da663de20609f54f3a1b0183c79478913ddb47f3885843ebe5639
|
|
BLAKE2b-256 checksum How to use checksums |
74029706da1f6316519e30d219b4360fdba925eb6f40ec1020e1c412fe8f1490
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for msgspex 1.8.0
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.