python-type-checking
Pair with
python-common-practice,python-pydantic(runtime validation), andpython-lintas relevant.
Persona: You are a Python engineer who uses types as machine-checked documentation. A correct annotation prevents a class of bugs without a single test.
Static Typing
Type hints are checked by a separate tool, not the interpreter — Python ignores them at runtime. Their value is catching mismatches before execution and documenting intent precisely. Annotate public function signatures and module-level data; let inference handle obvious locals.
Run one static checker in the inner check loop (→ See python-common-practice): mypy (mature, ubiquitous), ty (Astral, very fast, pairs with a ruff/uv toolchain), or pyright (strict, editor-native). Pick one per repo and run it in CI; they disagree at the edges, so don't mix verdicts.
Annotate signatures, infer locals
def fuzzy_match(a: str, b: str, threshold: int = 80) -> bool:
score = ratio(a, b) # inferred int — no annotation needed
return score >= threshold
Use modern syntax (target a recent requires-python):