Metadata-Version: 2.4
Name: msgspex
Version: 1.3.0
Summary: An extra msgspec collection of custom types, casters, encode hooks, decode hooks and deprecation system.
Author-email: luwqz1 <howluwqz1@gmail.com>
Maintainer-email: luwqz1 <howluwqz1@gmail.com>
License: MIT License
        
        Copyright (c) 2026 luwqz1
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Source, https://github.com/luwqz1/msgspextra
Project-URL: Bug Tracker, https://github.com/luwqz1/msgspextra/issues
Keywords: msgspec,custom types,decode hooks,encode hooks,msgspex,fast model,dataclasses,kungfu
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Typing :: Typed
Requires-Python: >=3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: kungfu-fp>=1.0.0
Requires-Dist: msgspec>=0.20.0
Dynamic: license-file

# msgspex

A collection of [`msgspec`](https://github.com/jcrist/msgspec) extensions: custom types, cast helpers, `decode hooks`, `encode hooks` and deprecation system.

## Quick Start

```python
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
```shell
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 on `kungfu` (`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 of `datetime.date`.
- `datetime` — meta-type that covers `StringTimestampDatetime`, `IntTimestampDatetime`, `FloatTimestampDatetime`, `ISODatetime` (alias: `isodatetime`), and `datetime.datetime`.
- `timedelta` — subclass of `datetime.timedelta` with cast support.
- `StrEnum`, `IntEnum`, `FloatEnum`, `BaseEnumMeta` — `enum` extensions for stable handling of unknown values.
- `Literal` — runtime type conceptually compatible with `typing.Literal`.
- `dataclasses.InitVar` — Passing vars to a `__post_init__` method.

### 3. OpenAPI-Oriented Types

- `Email` — `format: email`
- `IDNEmail` — `format: idn-email`
- `URI` — `format: uri`
- `URIReference` — `format: uri-reference`
- `IRI` — `format: iri`
- `IRIReference` — `format: iri-reference`
- `Hostname` — `format: hostname`
- `IDNHostname` — `format: idn-hostname`
- `IPv4` — `format: ipv4`
- `IPv6` — `format: ipv6`
- `JsonPointer` — `format: json-pointer`
- `RelativeJsonPointer` — `format: relative-json-pointer`
- `Regex` — `format: regex`
- `Int32`, `Int64` — range-limited integer types
- `Float32`, `Float64` — finite, range-limited floating-point types

`UUID`, `Decimal`, `date` and `time` already supported by `msgspec`.

## License
msgspex is [MIT licensed](https://github.com/luwqz1/msgspextra/blob/main/LICENSE)
