gawain
Require type annotations on Python assignments
TLDR
SYNOPSIS
gawain check [OPTIONS] PATHS...
DESCRIPTION
gawain checks that Python variables, parameters, returns, and class attributes are annotated, then optionally runs a type checker. The only subcommand is check.The default mode, obvious, allows a name to omit an annotation when the value's type is obvious and the name is not assigned again: a literal, a container of literals, or a constructor call. strict asks for an annotation on every assignment.Rules reported by the presence pass:- GW001 — assignment with no annotation- GW002 — parameter with no annotation- GW003 — function with no return annotation- GW004 — class attribute with no annotation, or self.x not declared on the class- GW010 — constant not annotated Final[T]- GW011 — bare Final with no type- GW020 — Any in an annotation- GW000 — file cannot be read- GW900 and GW901 — broken or unused suppressionSilence one line with a comment that names the code:
PARAMETERS
PATHS
Files or directories to check. At least one path is required.--no-types
Skip the type-checker pass. Presence checks still run.--format text|json
text (the default) or one JSON object.--mode MODE
How obvious values are judged. Overrides mode in [tool.gawain]. obvious is the default. strict requires an annotation on every assignment.--checker CHECKER
Type checker for the types phase. Overrides checker in [tool.gawain]. ty is the default. pyrefly is the other built-in choice.-h, --help
Show help and exit.
EXIT STATUS
- 0 — nothing to report. Warnings from the type checker do not fail the run.- 1 — presence or the type checker reported a problem- 2 — usage error, or the type checker could not run
