Skip to content

unsorted-dunder-slots

Pythonstyleno fixdefault: offpython/ruff

Reports a __slots__ list or tuple of strings that is not 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
...
...
__slots__ = ("b", "a")
...
python:
lint:
rules:
unsorted-dunder-slots: warn # off (default), warn, error

Enabled by the presets: python/ruff.

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