Skip to content

useless-import-alias

Pythonstyleno fixdefault: offpython/ruff

Reports import a as a and from m import a as a.

The alias repeats the name, so it adds nothing in an ordinary import. Type checkers read the form as an explicit re-export, but the rule still reports it.

To fix, remove the alias.

Reported
...
class A:
...
import os as os
...
python:
lint:
rules:
useless-import-alias: warn # off (default), warn, error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line useless-import-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 PLC0414 full