abstract-method / W0223#

Message emitted:

Method %r is abstract in class %r but is not overridden

Description:

Used when an abstract method (i.e. raise NotImplementedError) is not overridden in concrete class.

Problematic code:

class Pet:
    def make_sound(self):
        raise NotImplementedError


class Cat(Pet):  # [abstract-method]
    pass


import abc


class WildAnimal:
    @abc.abstractmethod
    def make_sound(self):
        pass


class Panther(WildAnimal):  # [abstract-method]
    pass

Correct code:

class Pet:
    def make_sound(self):
        raise NotImplementedError


class Cat(Pet):
    def make_sound(self):
        print("Meeeow")


import abc


class WildAnimal:
    @abc.abstractmethod
    def make_sound(self):
        pass


class Panther(WildAnimal):
    def make_sound(self):
        print("MEEEOW")

Created by the classes checker.