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 five 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.
  • Encode: writing valid values as portable data, the inverse of decode.
  • 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.3.0

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.3.0
File Size Uploaded Provenance Actions
pytypehint-1.3.0.tar.gz 289.2 kB With provenance Details for pytypehint-1.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 315.1 kB

Release files / pytypehint-1.3.0.tar.gz

Download URL pytypehint-1.3.0.tar.gz
Size 289.2 kB
Tags Source
SHA-256 checksum
How to use checksums
44f8ca5961d231d33d4a131ddc40d7a53ec14ff668b4fdc189e734c358fbc576
BLAKE2b-256 checksum
How to use checksums
500d3f931c8fb8d98c5e87186e5a7ad54a1a494b058f77cbb9bc471c300ee0a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

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

Download URL pytypehint-1.3.0-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90feb2ac9790276bd043825026bc29e349173748982dd033a4f7d89f86fa1c8c
BLAKE2b-256 checksum
How to use checksums
8f8f8a41ec6941ef99042178da4497cbcffdf8e9697f8289ed70875af6052e91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Security for pytypehint 1.3.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytypehint-1.3.0.tar.gz

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 Nov 13, 2026.

Transparency log

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.

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