Skip to content

abstract-base-class-without-abstract-method (B024)#

Derived from the flake8-bugbear linter.

What it does#

Checks for abstract classes without abstract methods.

Why is this bad?#

Abstract base classes are used to define interfaces. If an abstract base class has no abstract methods, you may have forgotten to add an abstract method to the class or omitted an @abstractmethod decorator.

If the class is not meant to be used as an interface, consider removing the ABC base class from the class definition.


from abc import ABC

class Foo(ABC):
    def method(self):

Use instead:

from abc import ABC, abstractmethod

class Foo(ABC):
    def method(self):