Registry / type-stubs / typing-validation

typing-validation

JSON →
library1.2.12pypypi✓ verified 84d ago

A lightweight, dependency-free runtime type-checking library for Python that validates values against arbitrary type annotations, including generics, TypeVars, and nested types. Current version is 1.2.12, released irregularly with incremental features and bug fixes.

pip install typing-validation
INSTALL
IMPORT
SIG · TYPING-VALIDATION
T
typing-validation
type-stubspythonv1.2.12
Install
1.6s avg
Import
22ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.12 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.024s · 18.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.020s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

validate
from typing_validation import validate
is_valid
from typing_validation import is_valid
InvalidTypeException
from typing_validation import InvalidTypeException

Basic usage: validate() raises on mismatch, is_valid() returns bool, assertion trick for performance.

from typing_validation import validate # Validate a simple type x: int = 10 try: validate(x, int) print("Valid") except InvalidTypeException as e: print(f"Invalid: {e}") # Use with assertions (compiled away with -O) from typing_validation import is_valid if is_valid(x, int): print("x is int")
Debug
Known issues
breakingIn v1.2.6, validate() return type changed from None to Literal[True]. Code relying on return value (e.g., if validate(...)) may break.
fix
Use is_valid() for boolean checks, or use assert validate(...) to suppress return value.
affects: >=1.2.6
deprecatedDo not use from typing_validation import valid; that import does not exist.
fix
Import validate or is_valid instead.
affects: all
gotchaValidate does not perform coercion; it only checks types. If validation passes, the value is unchanged.
fix
Cast or convert values explicitly before or after validation if needed.
affects: all
gotchaSupport for Type[T] is partial (see issue #18). Some edge cases with generic type variables may not raise.
fix
Test thoroughly with complex generics, or use alternatives like pydantic for strict runtime checks.
affects: >=1.2.10
Errors
Common errors & fixes
AttributeError: module 'typing_validation' has no attribute 'valid'
Typo: 'valid' is not exported; correct function is 'validate'.
fix
Change to 'from typing_validation import validate'
ImportError: cannot import name 'validate' from 'typing_validation'
Package not installed or installed incorrectly.
fix
Run 'pip install typing-validation' and ensure the virtual environment is activated.
Upgrade
Version history
1.2.12latest on PyPI · released Mar 18, 2025
Audit
Dependencies
typing_extensionsoptionalRequired for backward compatibility with Python < 3.11 (e.g., Self, TypeVarTuple)
numpyoptionalOptional: required for validation against NDArray[dtype] annotations
Agent activity
34 hits · last 30 days
node
26
OpenAI (training)
2
Resources
typing-validation — pip install typing-validation · libregistry