Skip to content

deprecated-typing-alias

Pythonstyleno fixdefault: offpython/ruff

Reports a subscript of typing.List, Dict, Set, FrozenSet, Tuple or Type when the target_version makes the builtin generic (3.9 and later).

Since Python 3.9 list[int], dict[str, int] and the other builtins are generic, and the typing aliases are deprecated. They also need an import that the builtin does not.

To fix, write the builtin, list[int] for List[int].

Reported
...
...
x: List[int]
...
python:
lint:
rules:
deprecated-typing-alias: warn # off (default), warn, error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line deprecated-typing-alias 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 UP006 full