Skip to content

useless-object-inheritance

Pythonstyleno fixdefault: offpython/ruff

Reports a class that has the builtin object as a base.

Every class of Python 3 inherits from object, so naming it changes nothing. The base was needed for new-style classes in Python 2.

To fix, remove the base.

Reported
...
Base = M = f = 1
class A(object):
pass
class B(Base, object, metaclass=M):
pass
...
python:
lint:
rules:
useless-object-inheritance: warn # off (default), warn, error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line useless-object-inheritance 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 UP004 full