They document intent, enable editor autocomplete, and let tools like mypy or pyright catch bugs before running. Pydantic and FastAPI also read them at runtime.
from typing import Optional
def top_k(scores: list[float], k: int = 3) -> list[int]: ...
def find(doc_id: str) -> Optional[dict]: ... # or dict | None