Type Annotation Workflow
We are gradually adding type annotations using Python 3.13+.
Workflow
- •
Check current coverage:
codeuv run plain code annotations <directory> --details
- •
Add annotations: Focus on function/method signatures (parameters and return types)
- •
Type check:
code./scripts/type-check <directory>
- •
Format:
./scripts/fix - •
Test:
./scripts/test <package> - •
Verify improvement:
codeuv run plain code annotations <directory>
- •
Add to validation: Once a directory reaches 100% coverage, add it to
FULLY_TYPED_PATHSinscripts/type-validate
Guidelines
- •Add
from __future__ import annotationswhen necessary - •Focus on public APIs and user-facing methods first
- •Don't annotate
__init__return types (type checkers inferNone) - •Use explicit
return Nonefor functions with-> Type | Nonereturn type - •Some Django-style ORM patterns are inherently difficult to type - that's okay
- •Goal is progress, not perfection
Example
bash
# Check coverage uv run plain code annotations plain/plain/assets --details # After adding annotations... ./scripts/type-check plain/plain/assets ./scripts/fix ./scripts/test plain uv run plain code annotations plain/plain/assets # Should show 100%