New linter Gawain forces type hints on every Python variable, not just functions
A developer released Gawain, an open-source tool that checks Python code for missing type annotations on variables, function parameters, return values, and class attributes, not just functions as existing tools like ruff's ANN rules do. After confirming all annotations are present, Gawain hands the code off to a type checker, either ty or pyrefly, to verify the declared types are actually correct. Example output shows Gawain flagging unannotated variables and class attributes before running the deeper type check.
GoKawiil's interpretation of the reporting above, not reported fact.
Existing Python type-checking tools such as mypy, Pyright, ty, and pyrefly can infer types automatically, so Gawain's stricter approach targets developers who want explicit annotations enforced rather than inferred, which the creator says improves code clarity by discouraging vague types like dict[str, Any]. This could appeal to teams enforcing strict coding standards, though it adds an extra layer of friction compared to tools that already infer types silently.
- Gawain enforces type annotations on variables and class attributes, beyond what tools like ruff or flake8-annotations require.
- It works in two stages: first checking for missing annotations, then running a type checker (ty or pyrefly) to validate correctness.
- The tool was built by a developer frustrated with vague typing patterns like dict[str, Any].
Source: github.com, 2026-11-15
Published there as: “Show HN: Gawain – Require type hints on all Python variables”
Read the original report → The summary and analysis above are GoKawiil's own, written from reporting by the source above. Facts and quotes belong to the original publisher.