# Gawain: Python 변수의 타입 힌트 검사
# Gawain: a type hint check for Python variables

- Site: https://select1.dev/2026-11-16 (English), https://select1.dev/ko/2026-11-16 (Korean)
- Entry: 037
- Published: 2026-11-16 (KST). Launch date: 2026-11-15
- Pick: Gawain <https://github.com/matheuzgomes/gawain> (source: Show HN)
- Verified: ran
- What: Gawain 은 Python 코드의 함수뿐 아니라 변수에도 타입을 표기하게 하는 프로덕트다. 타입 힌트가 빠진 곳을 찾아 알려 준다.
- What (en): Gawain is a product that requires type hints on Python variables as well as functions. It reports the places where a type hint is missing.
- Why: 오늘의 픽으로 선정한 이유는 함수 정의를 확인하지 않아도 변수의 타입을 알 수 있기 때문이다.
- Why (en): It is today’s pick because you can see a variable’s type without looking up a function’s definition.
- Verdict: 작동한다. README 예제와 결과가 같았고 httpx 의 타입 힌트 없는 변수를 찾았다.
- Verdict (en): It works. The output matched the README’s examples, and Gawain found variables with no type hint in httpx.
- Tags: python, type-hints, linter, rust

## Checked against the README

- [pass] shop.py 를 검사하면 타입 힌트가 빠진 곳 6건이 출력된다(6 errors (presence)) — README 의 shop.py 를 그대로 만들어 gawain check shop.py 를 실행하자, README 와 같은 6건이 같은 순서로 출력됐다
- [pass] 종료 코드는 오류가 없으면 0, 있으면 1, 사용법이 잘못됐거나 타입 검사 도구를 실행할 수 없으면 2 다(exits with 0, 1, 2) — 타입 힌트가 모두 있는 파일은 0, shop.py 는 1, 존재하지 않는 파일과 잘못된 옵션은 2 였다. pyrefly 를 설치하지 않고 --checker pyrefly 를 지정했을 때도 2 였다
- [pass] 기본 모드는 ruff 의 ANN 규칙보다 느리고 strict 모드는 비슷하다(0.46 s, 0.36 s, 0.35 s) — docs/benchmarks.md 의 명령으로 Python 3.13 표준 라이브러리 591개 파일을 30번씩 검사했다. 중앙값은 기본 모드 0.194초, strict 모드 0.139초, ruff 0.140초였다

## Measured

- 함수의 타입 힌트가 모두 있는 라이브러리 httpx 0.28.1 에서 Gawain 이 보고한 오류 건수: 8,828줄에서 615건 (pip 로 설치한 httpx 0.28.1 의 23개 파일을 gawain check httpx --no-types --format json 으로 검사하고 규칙별로 집계했다. 변수 349건, 클래스 속성 202건, Any 62건, 상수 2건이다)

## Progress (days after launch; full history https://select1.dev/2026-11-16/progress)

- day 3 (checked 2026-11-18) [active] commits since launch 6, stars 44, releases 0, contributors 1, last commit 2026-11-15
- day 7 (checked 2026-11-22) [quiet] commits since launch 6, stars 47, releases 0, contributors 1, last commit 2026-11-15

## 한국어

## 무엇이 문제인가

Python 에서는 변수와 함수에 타입을 표기할 수 있다. 이 표기를 타입 힌트라고 한다. 타입 힌트는 선택 사항이라서, 생략해도 코드는 실행된다. 타입 검사 도구 mypy 의 공식 문서에 따르면 mypy 는 타입 힌트가 없는 변수의 타입을 처음 대입한 값에서 추론한다. 그래서 타입 힌트가 없는 변수도 검사를 통과한다. `pair = load()` 처럼 함수의 반환값을 대입한 라인만으로는 변수의 타입을 알 수 없다. 타입을 알려면 그 함수의 정의를 찾아보거나 편집기가 추론해 보여 주는 타입을 확인해야 한다. 검사 도구 ruff 에는 타입 힌트를 요구하는 ANN 규칙이 있지만, 이 규칙은 함수의 타입 힌트만 요구한다.

## 어떻게 해결했나

Gawain 은 2026년 11월 15일 Hacker News 에 Show HN 글로 올라왔다. 제작자는 Marinho 다.

Gawain 은 검사를 두 단계로 실행한다. 첫 단계에서는 타입 힌트가 빠진 변수, 매개변수, 반환값, 클래스 속성을 찾는다. 이름이 대문자인 상수에는 `Final` 을 요구한다. `Final` 은 값을 바꿀 수 없다는 표기다. 빠진 곳이 없으면 둘째 단계에서 타입 검사 도구 ty 나 pyrefly 를 실행해, 표기한 타입이 올바른지 검사한다. 값만 봐도 타입을 알 수 있는 변수는 타입 힌트가 없어도 통과한다. `count = 0` 이나 `user = User("ada")` 가 그런 경우다. 이런 변수에도 타입 힌트를 요구하려면 strict 모드를 지정한다.

## 무엇이 다른가

첫째, 타입 힌트를 요구하는 범위가 다르다. mypy 와 ruff 의 ANN 규칙은 변수에 타입 힌트를 요구하지 않는다. Gawain 은 변수와 클래스 속성에도 요구해, 함수의 정의를 확인하지 않아도 대입한 라인에서 변수의 타입을 알 수 있다. 트레이드오프는 mypy 가 추론할 수 있는 타입도 직접 표기해야 한다는 점이다. 함수의 타입 힌트가 모두 있는 라이브러리 httpx 0.28.1 에서도 변수와 클래스 속성 551건이 보고됐다.

둘째, Any 를 다루는 방식이 다르다. Any 는 어떤 타입이든 허용한다는 표기다. mypy 는 기본 설정에서 Any 를 허용하고, `--disallow-any-explicit` 같은 옵션을 지정해야 금지한다. Gawain 은 타입 힌트에 Any 가 있으면 언제나 오류로 보고한다. 제작자는 README 에서 `dict[str, Any]` 가 싫어서 Gawain 을 만들었다고 밝혔다.

## 어떻게 만들었나

- 저장소에는 2026년 11월 11일부터 15일까지의 커밋 17개가 있다. 모두 제작자가 작성했다. 릴리스 태그는 v0.1.0 부터 v0.3.1 까지 4개다.
- Gawain 의 코드는 Rust 5,021줄이다. README 에 따르면 검사할 Python 코드는 ruff 의 파서인 ruff_python_parser 로 파싱한다.

## 실행해 보니

Linux 의 Python 3.13 가상 환경에 `pip install "gawain[ty]"` 로 Gawain 0.3.1 을 설치했다. README 의 예제, 직접 만든 파일, 공개 라이브러리를 검사했다.

1. 설치. 4초 만에 gawain 0.3.1 과 ty 0.0.100 이 설치됐다.
2. README 예제. shop.py 는 타입 힌트가 빠진 예제다. 검사하자 README 에 적힌 오류 6건이 같은 순서로 출력됐다. prices.py 는 반환 타입을 잘못 표기한 예제다. 여기서도 README 와 같이 ty 가 반환 타입 오류 1건을 보고했다.
3. 종료 코드. 타입 힌트가 모두 있는 파일은 0, 오류가 있는 파일은 1 이었다. 존재하지 않는 파일이나 잘못된 옵션을 지정하면 2 였다. pyrefly 를 설치하지 않고 `--checker pyrefly` 를 지정하자 설치 방법이 출력됐고, 종료 코드는 2 였다.
4. 검사하지 않는 변수. `pair = load()` 는 타입 힌트가 없는 변수(GW001)로 보고됐다. 같은 함수의 반환값을 `first, second = load()` 로 변수 두 개에 나눠 대입하자 보고되지 않았다. `for` 문과 `with` 문의 변수, `:=` 로 만든 변수도 보고되지 않았다. docs/rules.md 에 따르면 나눠 대입한 변수와 `for`, `with`, `:=` 의 변수는 검사 대상이 아니다.
5. 실제 라이브러리. httpx 0.28.1 의 23개 파일 8,828줄을 검사했다. 모두 615건이 보고됐다. 변수 349건, 클래스 속성 202건, Any 62건, 상수 2건이다. 매개변수와 반환값은 0건이었다.
6. 속도. docs/benchmarks.md 의 명령으로 Python 3.13 표준 라이브러리 591개 파일을 명령마다 30번씩 검사했다. 중앙값은 Gawain 기본 모드 0.194초, strict 모드 0.139초, ruff 의 ANN 규칙 0.140초였다. README 의 측정에서도 기본 모드가 strict 모드와 ruff 보다 느렸다.

```python title="edge.py 의 9~10행"
    pair = load()
    first, second = load()
```

```text title="터미널, gawain check edge.py --no-types"
[presence]
edge.py:9:5    GW001 variable 'pair' has no type annotation
edge.py:11:5   GW001 variable 'count' has no type annotation (it is reassigned on line 12)
edge.py:23:1   GW010 constant 'LIMIT' must be annotated as Final[T]
edge.py:25:17  GW020 'Any' is not allowed in type annotations
edge.py:27:17  GW901 unused suppression 'GW001'

5 errors (presence). Type check skipped until presence errors are fixed.
```

## 확인하지 못한 것

- pyrefly 로 실행하는 타입 검사. 오늘은 ty 만 설치했다. `pip install "gawain[pyrefly]"` 로 설치해 prices.py 를 검사해 보자.
- pre-commit 훅. README 에 따르면 훅은 Gawain 을 소스 코드에서 빌드하므로 Rust 1.97 이상이 필요하다.
- README 의 측정 대상인 CPython 3.14 표준 라이브러리 1,847개 파일. 오늘은 Linux 패키지로 설치된 Python 3.13 표준 라이브러리의 591개 파일을 검사했다.

## 판정

작동한다. README 예제와 결과가 같았고 httpx 의 타입 힌트 없는 변수를 찾았다. 다만 반환값을 여러 개로 나눠 대입한 변수와 `for` 문, `with` 문의 변수는 검사하지 않는다. 새 Python 프로젝트를 시작하는 경우에 써 볼 만하다.

## 얻어갈 것

- 검사 도구를 만들면 실제 코드에서 몇 건이 보고되는지 확인하자. 오늘 httpx 에서는 14줄에 1건꼴로 보고됐다.
- 문서의 예제에는 실제 출력을 그대로 넣자. 오늘 실행 결과를 README 의 출력과 대조해 같다는 것을 확인했다.
- 벤치마크를 공개할 때는 측정 명령도 함께 공개하자. 제작자가 공개한 명령으로 오늘 측정해 기본 모드가 ruff 보다 느리다는 것을 확인했다.

## English

## The problem

In Python, you can write the type of a variable or a function in the code. This notation is called a type hint. Type hints are optional, and the code runs without them. According to its official docs, the type checker mypy infers a variable’s type from the first value assigned to it when there is no type hint. So a variable can pass the check without a type hint. A line such as `pair = load()` assigns a function’s return value and does not show the variable’s type. To learn the type, a reader has to look up that function’s definition or rely on an editor. The linter ruff has ANN rules that ask for type hints, but these rules cover functions only.

## How it solves it

Gawain was posted to Hacker News as a Show HN on November 15, 2026. The maker is Marinho.

Gawain runs its check in two phases. The first phase finds each variable, parameter, return value and class attribute that has no type hint. For a constant with an uppercase name, Gawain requires `Final`. `Final` marks a value that must not change. If nothing is missing, the second phase runs the type checker ty or pyrefly to check that the type hints are correct. A variable passes without a type hint when its value alone shows its type. `count = 0` and `user = User("ada")` both pass. The strict mode asks for a type hint on those variables too.

## What is different

The first difference is where type hints are required. mypy and ruff’s ANN rules do not ask for type hints on variables. Gawain asks for them on variables and class attributes too, so the line that assigns a variable shows its type without a look at the function’s definition. The trade-off is that you also write types that mypy can infer. Even httpx 0.28.1, a library whose functions all have type hints, got 551 findings for variables and class attributes today.

The second difference is how Any is treated. Any is a type hint that accepts every type. mypy allows Any by default. According to its official docs, options such as `--disallow-any-explicit` forbid it. Gawain always reports Any in a type hint as an error. The README says the maker dislikes `dict[str, Any]` and built Gawain for that reason.

## How it was built

- The repository has 17 commits from November 11 to November 15, 2026. The maker wrote all of them. There are 4 release tags, from v0.1.0 to v0.3.1.
- Gawain’s code is 5,021 lines of Rust. According to the README, it uses ruff’s parser, ruff_python_parser, to parse the Python code it checks.

## Running it

I installed Gawain 0.3.1 with `pip install "gawain[ty]"` in a Python 3.13 virtual environment on Linux. I checked the README’s examples, files of my own and a public library.

1. Install. Installation took 4 seconds and installed gawain 0.3.1 and ty 0.0.100.
2. README examples. shop.py is an example with missing type hints. Gawain printed the same 6 findings as the README, in the same order. prices.py is an example that declares the wrong return type. For this file, ty reported 1 return type error, as in the README.
3. Exit codes. A file with every type hint in place gave 0, and a file with errors gave 1. A missing file or a wrong option gave 2. When I passed `--checker pyrefly` without pyrefly installed, Gawain printed how to install it, and the exit code was 2.
4. Variables it does not check. Gawain reported `pair = load()` as a variable with no type hint (GW001). When I split the same return value into two variables with `first, second = load()`, Gawain reported nothing. Gawain also did not report the variables of `for` and `with` statements, or a variable made with `:=`. According to docs/rules.md, Gawain does not report the names in an unpacking assignment or the targets of `for`, `with` and `:=`.
5. A real library. I checked the 23 files and 8,828 lines of httpx 0.28.1. Gawain reported 615 findings in total. They were 349 variables, 202 class attributes, 62 uses of Any and 2 constants. It reported 0 parameters and 0 return values.
6. Speed. With the commands from docs/benchmarks.md, I checked the 591 files of the Python 3.13 standard library 30 times per command. The medians were 0.194 seconds for Gawain’s default mode, 0.139 seconds for the strict mode and 0.140 seconds for ruff’s ANN rules. In the README’s measurement, the default mode was also slower than the strict mode and ruff.

```python title="edge.py, lines 9 and 10"
    pair = load()
    first, second = load()
```

```text title="Terminal, gawain check edge.py --no-types"
[presence]
edge.py:9:5    GW001 variable 'pair' has no type annotation
edge.py:11:5   GW001 variable 'count' has no type annotation (it is reassigned on line 12)
edge.py:23:1   GW010 constant 'LIMIT' must be annotated as Final[T]
edge.py:25:17  GW020 'Any' is not allowed in type annotations
edge.py:27:17  GW901 unused suppression 'GW001'

5 errors (presence). Type check skipped until presence errors are fixed.
```

## Not checked

- The type check with pyrefly. Today only ty was installed. The next step is to install pyrefly with `pip install "gawain[pyrefly]"` and check prices.py.
- The pre-commit hook. According to the README, the hook builds Gawain from source, so it needs Rust 1.97 or newer.
- The 1,847 files of the CPython 3.14 standard library that the README measured. Today’s run checked the 591 files of the Python 3.13 standard library installed from a Linux package.

## Verdict

It works. The output matched the README’s examples, and Gawain found variables with no type hint in httpx. But it does not check variables assigned together, as in `first, second = load()`, or the variables that `for` and `with` statements define. It is worth trying if you are starting a new Python project.

## What to take away

- If you build a checker, find out how many findings it reports on real code. Today Gawain reported about 1 finding for every 14 lines of httpx.
- Put the exact output next to each example in your docs. Today I compared the run with the README’s output and confirmed that they were the same.
- When you publish a benchmark, publish the commands too. Today I reran the README’s benchmark commands, and the default mode was slower than ruff, as in the README.

## Launches the same day

- DeepSeek V3 in pure JAX <https://github.com/Vaibhaav-Tiwari/deepseek-v3-jax> (Show HN, 268): 모델 구현 예제. DeepSeek V3 의 구조를 JAX 코드 190줄로 작성했다.
- Gawain <https://github.com/matheuzgomes/gawain> (Show HN, 67): Python 검사 도구. 함수뿐 아니라 변수에도 타입 힌트를 요구한다.
- Jamaican Flag Alphabet Font <https://bobbiec.github.io/jamaican-font.html> (Show HN, 52): 글꼴. 자메이카 국기를 바탕으로 한 알파벳이다.
- Turbo-Browser-MCP <https://github.com/Tthanh2k6/turbo-browser-mcp> (Show HN, 46): 브라우저 MCP 서버. 여러 동작을 한 번에 실행하고 변경된 부분만 반환한다.
- db-branch <https://github.com/db-branch/db-branch> (Show HN, 25): 데이터베이스 브랜치 도구. ZFS 로 데이터베이스의 복사본을 몇 초 만에 만든다.
- Rakazo <https://www.producthunt.com/products/rakazo> (Product Hunt, 275): 오픈소스 AI 봇. Grok Bot 대신 직접 운영한다.
- Frevana Multiplayer <https://www.producthunt.com/products/frevana-2> (Product Hunt, 192): 업무용 AI 도구. 팀원 여러 명이 함께 사용한다.
- Tulvo <https://www.producthunt.com/products/tulvo> (Product Hunt, 178): 업무 관리 도구. 여러 작업을 작업 공간 하나에서 관리한다.

## Getting started

- Steps: pip install "gawain[ty]" ; gawain check src/
- Needs: Python 3.10 이상.
- Cost: MIT, 무료.
- Note: 제작자는 타입 검사 도구 ty 가 베타라서 버전에 따라 검사 결과가 달라질 수 있다고 밝혔다. --no-types 옵션을 지정하면 ty 를 실행하지 않고 타입 힌트가 있는지만 검사한다.
