Skip to content

unused-annotation

Pythonsuspiciousno fixdefault: offpython/ruff

Reports a local variable that is annotated without a value and never read.

x: int in a function declares a type and binds nothing. If the name is never used afterwards it is dead code left from a change.

To fix, remove it, or assign a value that is used.

Reported
...
pass
_ = 5
annotated: int
kept: int = 6
__tracebackhide__ = True
return used, kept
...
python:
lint:
rules:
unused-annotation: warn # off (default), warn, error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line unused-annotation in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ruff F842 full