# python-fastapi FastAPI conventions: pydantic v2, async-first endpoints, dependency injection, OpenAPI hygiene. ```bash npx rulepack add python-fastapi ``` ## What it covers - Tooling baseline: Python 3.12+, `uv`/`pdm` for env+lock, type hints everywhere (`mypy --strict`), Pydantic v2 (`model_dump()`, not `.dict()`) - Async-first endpoints: `async def` handlers by default, with `asyncio.to_thread()` (or a sync route) instead of blocking the event loop with sync I/O - Typed request/response contracts: Pydantic models for bodies plus `response_model` so the generated OpenAPI stays accurate - Explicit parameter and error handling: `Annotated[..., Path(...)]` / `Annotated[..., Query(...)]` over bare defaults, and `HTTPException` with explicit `status_code` + `detail` - A framework-agnostic project shape (`routers/`, `schemas/`, `services/`, `deps.py`) with dependency injection instead of mutable global state ## Source Rules align with the official FastAPI documentation: https://fastapi.tiangolo.com/ ## License MIT