Type-Hinting Skill
Adding and tightening type annotations - an Agent Skill for Python 3.14 static typing.
Search across all documentation pages
Adding and tightening type annotations - an Agent Skill for Python 3.14 static typing.
Reviews modules and adds types: function signatures, TypedDict, Protocol, TypeVar bounds, assert isinstance narrowing, fixes Any leakage, configures mypy or pyright in pyproject.toml, and enables CI gate on changed paths.
Any or untyped public API| Input | Why |
|---|---|
| Checker | mypy vs pyright team standard |
| Strictness | strict per module vs whole repo |
| Public API surface | __all__ and exported names first |
| Third-party stubs | types-* packages needed |
| Django/FastAPI | plugin config differences |
pyproject.toml [tool.mypy] or [tool.pyright]TYPE_CHECKING imports for circular deps# type: ignore audit with ticket refs only when unavoidableuv run mypy src/package clean on scopedef foo(x: int) -> str.type: ignore[arg-type] + comment.uv sync --extra dev
uv run mypy src/myservice
uv run pyright src/myservice # if pyright is standard
uv run pytest -qfrom collections.abc import Sequence
from typing import Protocol
class SupportsClose(Protocol):
def close(self) -> None: ...
def shutdown_all(resources: Sequence[SupportsClose]) -> None:
for r in resources:
r.close()pyright faster in editors; mypy mature plugin ecosystem - pick one per repo.
Use django-stubs in mypy plugins - skill documents extra deps.
Stack versions: This page was written for Python 3.14.0 (stable 3.14, maintenance 3.13), FastAPI 0.115+, Django 5.2, Flask 3.1, Pydantic 2, PyTorch 2.6+, pandas 2.2+, Polars 1.x, ruff 0.9+, and uv 0.6+.
Reviewed by Chris St. John·Last updated Jul 16, 2026