annotated-types

Reusable constraint metadata objects for use with Python's typing.Annotated

Library
PyPI
v0.8.0
610stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
55/100Fair
Development Activity44
Maintenance28
Community52
Maturity56
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture75
Code Quality82
Innovation70
Learning Curve85

annotated-types provides a small set of standardized metadata objects — Gt, Ge, Lt, Le, Interval, MultipleOf, MinLen, MaxLen, Len, Timezone, Predicate, and Doc — designed to be attached to types via PEP 593’s typing.Annotated. Rather than every validation library inventing its own constraint vocabulary, annotated-types gives them a shared, statically-inspectable representation that tools, IDEs, and runtime validators can all agree on.

It underpins constraint handling in Pydantic v2 and is recognized by FastAPI, msgspec, and other typing-aware libraries, making it a foundational piece of the modern Python typing ecosystem rather than a library developers typically import directly for standalone use.

What You Get

  • Comparison constraints: Gt, Ge, Lt, Le, and a combined Interval type
  • Collection/string constraints: MinLen, MaxLen, and Len
  • MultipleOf for numeric divisibility constraints
  • Timezone constraint for datetime/time annotations
  • Predicate and GroupedMetadata for arbitrary runtime checks and downstream composition
  • Prebuilt generic aliases like LowerCase, IsFinite, and IsDigit for common patterns

Common Use Cases

  • Declaring field-level constraints consumed by Pydantic v2 models via Annotated types
  • Building a custom validation library that needs to interoperate with the broader typing ecosystem
  • Adding static, tool-inspectable documentation and constraints to function signatures
  • Writing framework-agnostic type aliases (e.g. a shared ‘PositiveInt’) that multiple validators can consume identically

Under The Hood

Architecture: The entire implementation lives in a single module, annotated_types/__init__.py (~400 lines), defining frozen dataclasses for each constraint (Gt, Ge, Lt, Le, Interval, MultipleOf, MinLen, MaxLen, Len, Timezone, Predicate, Not, Doc) plus a GroupedMetadata protocol that downstream libraries implement to expose composite constraint bundles that iterate into individual metadata objects. There is no runtime enforcement logic at all — the package is purely descriptive metadata meant to be interpreted by consuming validators.

Tech Stack: Pure Python with zero runtime dependencies, using dataclasses and typing_extensions/typing for structural types, targeting Python 3.10 through 3.14. Packaging uses a standard pyproject.toml with Hatchling-style metadata and a Makefile for local dev tasks.

Code Quality: Tests are split between tests/ (test_main.py, test_grouped_metadata.py) and an in-package annotated_types/test_cases.py that other libraries can import and reuse to verify their own interpretation of these metadata types against a shared conformance suite — an unusually thoughtful design for an ecosystem-spec package. Type hints are exhaustive and the codebase is fully typed (Typing :: Typed classifier), with CI running across all supported Python versions per pyproject classifiers.

API Design: The API is deliberately minimal — plain dataclass constructors (Gt(0), Len(1, 10)) with obvious, self-documenting names and no configuration ceremony, designed to be composed inside Annotated[T, ...] with zero learning curve for anyone already familiar with PEP 593. Prebuilt generic aliases (LowerCase, IsFinite, IsDigit) further reduce boilerplate for common cases, and the README doubles as a de facto specification document for implementers.

Used by 10 apps in this directory

Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
C++
69%
Apache 2.0

ClickHouse

Databases · Analytics · Data Engineering

49,325

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
C++69%
Python13%
Updated today
Python
63%
Apache 2.0

GPT Researcher

Productivity · AI Assistants

29,039

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
88
Repo Health
91
Technical
64
Dependency
Built with
Python63%
TypeScript23%
Updated 1 months ago
TypeScript
97%
Other

GrowthBook

Developer Tools · Analytics · Monitoring

8,138

Open source feature flags, A/B testing, and warehouse-native experimentation that queries your existing data infrastructure—no data movement required.

View details
92
Repo Health
85
Technical
66
Dependency
Built with
TypeScript97%
Updated today
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,083

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
62
Repo Health
81
Technical
66
Dependency
Built with
TypeScript91%
Updated 3 days ago
Python
83%
Apache 2.0

knowhere

AI Development · Developer Tools

2,515

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
83
Repo Health
75
Technical
70
Dependency
Built with
Python83%
HTML16%
Updated today
TypeScript
97%
MIT

Promptfoo

AI Development

24,362

An open-source CLI and library for evaluating and red-teaming LLM applications — replace trial-and-error prompt engineering with systematic evals, vulnerability scanning, and CI/CD integration.

View details
90
Repo Health
73
Technical
68
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
98%
Apache 2.0

rowboat

AI Assistants · AI Development

17,323

Build, test, and deploy multi-agent AI workflows with a visual editor, RAG data sources, MCP tool integration, and a production-ready REST API.

View details
85
Repo Health
72
Technical
65
Dependency
Built with
TypeScript98%
Updated today
TypeScript
60%
MIT

Scalar

Developer Tools

15,944

Beautiful, interactive OpenAPI documentation with a built-in offline-first API client and multi-language code generation — all in one open-source platform.

View details
90
Repo Health
89
Technical
66
Dependency
Built with
TypeScript60%
Vue35%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search