Skip to main content

pytypehint

Define data once with ordinary Python type hints and dataclasses. pytypehint compiles them into strict schemas that validate input with exact types and no implicit coercion, build nested dataclasses, and export a portable description another process can read.

Use @immutable for deeply immutable models that validate themselves and reuse already validated children. pytypehint is the schema and validation core of func-to-web.

from dataclasses import dataclass
from typing import Annotated
from pytypehint import Min, struct_of

@dataclass
class Item:
    name: str
    quantity: Annotated[int, Min(1)] = 1

schema = struct_of(Item)
item = schema.build({"name": "Pen"})          # Item(name='Pen', quantity=1)
schema.build({"name": "Pen", "quantity": 0})  # SchemaValueError: quantity

The full documentation is at https://offerrall.github.io/pytypehint/.

Documentation

  • Overview: immutable models, portable data, field metadata and the four operations.
  • Immutable models: the @immutable contract, allowed fields, reuse and Python behavior.
  • Types and API: which hints compile to which shapes, and the public API.
  • Atoms: constraints and notation per shape, file names, layering and extras.
  • Build: validating and constructing instances or keyword arguments, union selection and errors.
  • Resolve: validated dictionaries with defaults filled at the current level.
  • Decode: restoring portable values such as dates, enums and tuples before validation.
  • Tuples: fixed, variadic and empty tuples and the Tuple shape.
  • Defaults: certification and rematerialization of default values.
  • Portable contract: the JSON-compatible schema document returned by to_dict().
  • Limits: rejected definitions, option identity and runtime limits.
  • Design: what the core owns, what consumers own, and why.

Metadata

Release files for pytypehint 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytypehint 1.2.3
File Size Uploaded
pytypehint-1.2.3.tar.gz 284.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytypehint 1.2.3
File Interpreter ABI Platform
pytypehint-1.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 309.7 kB

Release files / pytypehint-1.2.3.tar.gz

Download URL pytypehint-1.2.3.tar.gz
Size 284.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8284139373521cc17c3591a37574ea8178af385d7132910c21aaa27d029666b8
BLAKE2b-256 checksum
How to use checksums
a56138aea6891b3c4b07cd0f733e91bade3398aaecbacaeb0c588185b3c9f8fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 29, 2026.

Transparency log

Release files / pytypehint-1.2.3-py3-none-any.whl

Download URL pytypehint-1.2.3-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
264a9dbd0e12585a8d20d0d97163bc90cad010d4567c677331c98d4a69ba707c
BLAKE2b-256 checksum
How to use checksums
3b502129a8b4973e01dd6cd91a9179e220490f99c41e72620f2ea22c8b5a27b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.3 This release

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.3

2 release files

0.0.1

2 release files

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