Skip to content

useless-class-metaclass-type (UP050)

Derived from the pyupgrade linter.

Fix is sometimes available.

This rule is unstable and in preview. The --preview flag is required for use.

What it does

Checks for metaclass=type in class definitions.

Why is this bad?

Since Python 3, the default metaclass is type, so specifying it explicitly is redundant.

Even though __prepare__ is not required, the default metaclass (type) implements it, for the convenience of subclasses calling it via super().

Example

class Foo(metaclass=type): ...

Use instead:

class Foo: ...

References