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.2

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.2
File Size Uploaded
pytypehint-1.2.2.tar.gz 284.0 kB Details

Built distribution (wheel)

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

Total release size: 309.7 kB

Release files / pytypehint-1.2.2.tar.gz

Download URL pytypehint-1.2.2.tar.gz
Size 284.0 kB
Tags Source
SHA-256 checksum
How to use checksums
681eab118b572284b320928d336aba637499c0584365a22b3e20f28c7d611894
BLAKE2b-256 checksum
How to use checksums
a0649360ad02bc381e46aebab25a72b9cc944be461d7862d108b06921d41442d
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.2-py3-none-any.whl

Download URL pytypehint-1.2.2-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f169883b30c724f61925c80b6a83250828ee760c22726246ea046f723dffcc82
BLAKE2b-256 checksum
How to use checksums
e25b41a90028a38c4d85b7465b1f749f490f69207689a58c8e7257f17dd03acd
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

1.2.3

2 release files

This release

1.2.2 This release

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