Skip to content

unsorted-dunder-all

Pythonstyleno fixdefault: offpython/ruff

Reports an __all__ list or tuple of strings that is out of order: constants (upper case) first, then classes (capitalized), then the rest, each group in natural order.

A sorted list is easy to scan for a name, a merge does not put the same name in twice, and an added name has one obvious place.

To fix, sort the list.

Reported
...
...
__all__ = ["b", "a"]
...
python:
lint:
rules:
unsorted-dunder-all: warn # off (default), warn, error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line unsorted-dunder-all 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 RUF022 full