annotated-types
Reusable constraint types to use with typing.Annotated
Decision gist · record as of 2026-08-14
Yes. annotated-types is a lightweight, zero-dependency standard library for constraint metadata that integrates seamlessly with Python's type system. It has no security vulnerabilities, active maintenance, and is widely adopted (top 100 PyPI). Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with constraints for validation frameworks to consume.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Installation is frictionless—no runtime dependencies, pure Python wheel.
- The package is actively maintained with a recent release and no known vulnerabilities.
License · maintenance · safety
MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.
last release 2026-07-23 (22 days) · last repo commit 2026-07-24 · 608 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 871,281,123 downloads/mo, #32 on PyPI
Alternatives
Verify before relying
from typing import Annotated
from annotated_types import Gt, Len, Predicate
age: Annotated[int, Gt(18)]
my_list: Annotated[list[int], Len(0, 10)]
factors: list[Annotated[int, Predicate(lambda x: x > 0)]]- Whether downstream libraries actively interpret these metadata objects for validation or if they are primarily documentation aids.
- Performance characteristics when used with large collections or complex predicate functions.
What it is and what it does
annotated-types provides a standard library of metadata objects designed to work with PEP-593's `typing.Annotated`. Instead of writing custom constraint logic, you attach metadata like `Gt(18)`, `Len(0, 10)`, or `Predicate(func)` to type annotations to express bounds, collection sizes, timezone requirements, units, and arbitrary runtime checks. The package itself performs no validation—it simply defines the metadata objects and documents how downstream libraries should interpret them.
This is useful for libraries that need to express validation rules in a standardized, inspectable way. Type checkers and validation frameworks can read these annotations and apply constraints without requiring special logic for each library. The metadata objects cover common cases: numeric bounds (`Gt`, `Ge`, `Lt`, `Le`, `Interval`), collection sizes (`MinLen`, `MaxLen`, `Len`), divisibility (`MultipleOf`), timezone constraints, units, and generic predicates.
Use it for
- Annotate function parameters with bounds (e.g., `age: Annotated[int, Gt(18)]`) for validation frameworks to enforce at runtime.
- Express collection size constraints (e.g., `items: Annotated[list, Len(1, 100)]`) for API schemas and data validators.
- Attach timezone or unit metadata to datetime and numeric types for downstream libraries like pint or astropy to interpret.
- Use predicate markers (e.g., `Predicate(str.islower)`) for custom validation logic in data validation or serialization libraries.
- Document type constraints in a machine-readable format for code generation, API documentation, or schema validation tools.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
annotated-types is a lightweight, zero-dependency standard library for constraint metadata that integrates seamlessly with Python's type system. It has no security vulnerabilities, active maintenance, and is widely adopted (top 100 PyPI). Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with constraints for validation frameworks to consume.
Install
annotated-types on PyPI
Before you install
Installation is frictionless—no runtime dependencies, pure Python wheel. The package is actively maintained with a recent release and no known vulnerabilities.
Requires Python 3.10 or later.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.
Quickstart
from typing import Annotated
from annotated_types import Gt, Len, Predicate
age: Annotated[int, Gt(18)]
my_list: Annotated[list[int], Len(0, 10)]
factors: list[Annotated[int, Predicate(lambda x: x > 0)]]
Verify before relying
- Whether downstream libraries actively interpret these metadata objects for validation or if they are primarily documentation aids.
- Performance characteristics when used with large collections or complex predicate functions.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 22 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 871,281,123 / month, #32 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaEnvironment :: ConsoleEnvironment :: MacOS XIntended Audience :: DevelopersIntended Audience :: Information TechnologyLicense :: OSI Approved :: MIT LicenseOperating System :: POSIX :: LinuxOperating System :: UnixProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed |
Evidence: annotated_types-0.8.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “typing.Annotated metadata constraints”
- annotated-typesProvides reusable metadata objects for use with PEP-593…
- zope.schemaDefines structured data schemas for Python objects using…
- schemainspectInspects PostgreSQL database schemas to extract metadata about…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
Determines platform-specific directories for application data, config, cache, logs, and user media folders across macOS, Windows, Linux, and Android.
See also phantom-types · typing-utils · beartype · type-enforced · param · annotated-doc · typing-extensions · griffe-typingdoc · typing-inspect · patito