typing-validation
A library to perform runtime validation of Python objects using type hints.
What it is and what it does
typing-validation is a runtime type checker that validates Python objects against type hints. It offers three entry points: `validate()` for one-off checks that return True or raise a detailed ValidationError; `validator()` for building a reusable checker when the same type is validated many times; and `compiled_validator()` for generating specialized Python code when validation happens at very high volume. The library reports validation failures with precise location information (e.g., which dict key or list index failed), making it useful for catching data shape problems in production code or during testing.
The package supports common type forms (list, dict, tuple, union, optional, generic classes) and rejects unsupported types upfront rather than silently passing them. It includes an extension mechanism for NumPy arrays and custom classes. No runtime dependencies means installation is friction-free. The library is actively maintained and typed throughout.
Use it for:
- Validate API request payloads or configuration dicts against a type hint before processing them.
- Check data shape in data pipelines where type mismatches indicate upstream errors.
- Gate validation behind assertions so it compiles out entirely under Python's -O flag.
- Build a fast reusable validator when the same type is checked repeatedly in a loop.
- Inspect whether a complex type is validatable before attempting validation, using can_validate().
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Runtime validation of Python objects against type hints, with three speed tiers: one-off checks, cached validators, and compiled validators optimized to near hand-written performance.
Yes, if you need runtime type validation and are on Python 3.14+. The library is actively maintained, has no dependencies, and offers a clear performance ladder (one-off, cached, compiled) for different validation frequencies. The copyleft license is a constraint in proprietary contexts but not a blocker for open-source or internal use. No known vulnerabilities.
Install
typing-validation on PyPI
pip
pip install typing-validationuv
uv add typing-validationpoetry
poetry add typing-validationInstalling typing-validation
Before you install
Low friction: pure Python wheel with no runtime dependencies. Active maintenance, last release 27 days ago.
License in practice
LGPL-3.0-or-later (copyleft): derivative works and distributions must preserve the license and source availability; suitable for internal tools and open-source projects, but requires care in proprietary contexts.
Quickstart
pip install typing-validation
from typing_validation import validate, validator
# One-off check
validate([1, 2, 3], list[int]) # returns True or raises ValidationError
# Reusable validator for many values
check = validator(list[int])
check([1, 2, 3])
Requires Python 3.14 or later.
Verify before relying
- Whether the compiled_validator performance figures (23 ns per type-node) are reproducible on typical developer machines or are specific to the benchmark environment.
- Scope of NumPy array type support and whether other scientific libraries are covered by the extension mechanism.
Package facts
| License | LGPL-3.0-or-later (copyleft) |
| Python support | capped below the current Python release (>=3.14) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 27 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 150,283/month — #10,967 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: typing_validation-2.2.1-py3-none-any.whl
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
typepyTypepy checks, validates, and converts Python…
permissive · top 5,000 on PyPI
typishTypish provides runtime type checking and…
permissive · top 5,000 on PyPI
nptypingProvides type hints and runtime type checking…
permissive · top 15,000 on PyPI
pyre-extensionsProvides typing extensions for the Pyre type…
permissive · top 5,000 on PyPI
typing-inspectProvides runtime inspection utilities for…
permissive · top 1,000 on PyPI
pyvalidpyvalid is a Python data validation tool that…
permissive · top 15,000 on PyPI
schemaValidates Python data structures (dicts, lists,…
permissive · top 1,000 on PyPI
fastjsonschemaValidates JSON data against JSON Schema…
permissive · top 1,000 on PyPI
type-enforcedEnforces Python type annotations at runtime…
permissive · top 15,000 on PyPI
colanderColander deserializes and validates data…
permissive · top 15,000 on PyPI