--- id: runtype version: "0.5.3" license: MIT license_treatment: permissive maintenance: active --- # runtype — Type dispatch and validation for run-time Python License: permissive · Maintenance: active · Downloads: 649.1K/mo ## What it is and what it does Runtype is a pure-Python type system for runtime validation and dispatch. It provides three main capabilities: a validation layer (`isa`, `issubclass`) that understands `typing` module constructs and constraints; an enhanced dataclass decorator that validates and optionally casts field values at instantiation; and a multiple-dispatch decorator that routes function calls to the most specific type-matching implementation. The package is designed for developers who need runtime type safety without external C dependencies. It supports forward references, generic types, and custom type constraints. The dataclass mode can auto-cast values (like Pydantic) and sample large collections for faster validation. All three modules are built on an internal type system that the documentation claims outperforms comparable libraries like Pydantic v1 and beartype in pure-Python benchmarks. Use it for: - Add runtime type validation to dataclasses with automatic value casting and constraint checking. - Implement multiple-dispatch functions that route to different implementations based on argument types. - Validate complex nested types (e.g., `dict[str, list[int]]`) at runtime without external type checkers. - Build custom type systems with generics and phantom types for domain-specific validation. - Replace `isinstance` checks with smarter type validation that understands `typing` module annotations. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Runtype provides runtime type validation, dataclass enhancement with type checking, and multiple-dispatch function routing based on argument types, all without external dependencies. Yes. Runtype is actively maintained, has no dependencies, supports current Python versions (3.8+), carries no known vulnerabilities, and offers a cohesive toolkit for runtime type validation and dispatch. Install it if you need runtime type safety in dataclasses or want to use multiple dispatch without external dependencies. The permissive MIT license removes any legal friction. ## Install pip install runtype uv add runtype poetry add runtype ## Installing runtype Before you install: Installation is straightforward with no runtime dependencies. The package is actively maintained with a recent release on 2025-03-03 and an active repository. License in practice: MIT license permits unrestricted use, modification, and distribution in both open and closed-source projects. Quickstart: pip install runtype from runtype import isa, dataclass, multidispatch as md assert isa({'a': 1}, dict[str, int]) @dataclass(check_types='cast') class Person: name: str p = Person('Alice') @md def process(x: int): return x * 2 @md def process(x: str): return x.upper() process(5) # Returns 10 Requires Python 3.8 or later. Verify before relying: - Whether the claimed performance advantage over Pydantic v1 and other type checkers holds across all use patterns and Python versions. - Compatibility and behavior with Python 3.13+ given the current support ceiling. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 649.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags runtime type validation, type dispatch functions, dataclass type checking, multiple dispatch decorator, typing module validation, runtime type constraints, fast type checking, type-validation, multiple-dispatch, dataclass-enhancement [View on SkillFed](https://skillfed.io/packages/runtype) · [View on PyPI](https://pypi.org/project/runtype/)