# Gawain - Enforce type hints on all Python variables

Original title: Show HN: Gawain – Require type hints on all Python variables

> Hacker News story 50504072 · language: en · submitted 2026-11-15
> Web version: https://zeli.app/story/50504072
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 67 · by [MarinhoD](<https://news.ycombinator.com/user?id=MarinhoD>) · 💬 61
[original](<https://github.com/matheuzgomes/gawain>) · [HN discussion](<https://news.ycombinator.com/item?id=50504072>)

## Summary

Gawain is a fast linter that requires type annotations on every Python variable, parameter, return, and class attribute, then runs a type checker like ty or pyrefly to verify correctness. Unlike ruff's ANN rules or flake8-annotations, which only check functions, Gawain also demands annotations on variables and class attributes, eliminating vague dict[str, Any] types. It offers obvious and strict modes, integrates with pre-commit, and runs in milliseconds—scanning the entire CPython standard library in under half a second. Install via pip or uv with the appropriate extra, and use it to enforce consistent typing across your codebase.

## Key quote

> I built gawain only because I hate dict[str, Any] and wanted to do something about it.

## HN discussion (61 comments)

### [santiagobasulto](<https://news.ycombinator.com/item?id=50504966>)

> This is awful. I love type correctness, but going all the way to flag PORT=8080? There should be a basic level of type inference.
>
> Especially for “typed” languages that have done typing very wrong, as Python or Typescript.

### [gavmor](<https://news.ycombinator.com/item?id=50504334>)

> Gawain, the finest night alive (literally Þe most kydde knyȝtez vnder Krystes seluen) committed one indisputable, albeit minor, transgression under a regime of unsparing precision.
>
> \> ȝe han redily rehersed, bi resoun ful trwe,
>
> Alle þe covenauntz þat I yow kende...
>
> ("You have readily recapitulated, by fully accurate accounting, all covenants that I declared.")
>
> I can't think of a more fitting name except, perhaps, the speaker of these lines: the exacting Lord Bertilak.

### [orsorna](<https://news.ycombinator.com/item?id=50504374>)

> This is cool. And I appreciate the cheeky comment about not using this program if your IDE or whatever does type checking already :)
>
> But honestly, after I realized I appreciate types being enforced, I started writing in different languages. I rarely return to Python unless I'm scripting something that doesn't require longevity.

### [michalc](<https://news.ycombinator.com/item?id=50504823>)

> I think similar to `dict[str, Any]`, my (justified?) recent pet peeve is `| None`.
>
> I posted this yesterday pretty much on that: https://charemza.name/blog/posts/software/type-safety/type-s...

### [Garlef](<https://news.ycombinator.com/item?id=50504301>)

> Maybe not for me but I love the attitude.
>
> (And actually, my personal objection is incidental: The python syntax is not pretty to begin with and the situation does not improve with even more visual verbosity)

---

## Cite

- Page: https://zeli.app/story/50504072
- Date: 2026-11-15
- Source: github.com (https://github.com/matheuzgomes/gawain)
- Hacker News: https://news.ycombinator.com/item?id=50504072

## Other languages

- zh: https://zeli.app/zh/story/50504072 · markdown: https://zeli.app/zh/story/50504072.md
- ja: https://zeli.app/ja/story/50504072 · markdown: https://zeli.app/ja/story/50504072.md
- ko: https://zeli.app/ko/story/50504072 · markdown: https://zeli.app/ko/story/50504072.md
- de: https://zeli.app/de/story/50504072 · markdown: https://zeli.app/de/story/50504072.md
- es: https://zeli.app/es/story/50504072 · markdown: https://zeli.app/es/story/50504072.md
- ru: https://zeli.app/ru/story/50504072 · markdown: https://zeli.app/ru/story/50504072.md
