Python

Python

Made by DeepSource

Abstract method does not raise NotImplementedError PTC-W0053

Anti-pattern
Major
Autofix

Abstract methods should raise NotImplementeError when they require derived classes to override the method, or while the class is being developed to indicate that the real implementation still needs to be added.

Refer to the docs to read more about NotImplementedError.

Not preferred:

import abc

class Vehicle:
    __metaclass__ = abc.ABCMeta

    @abc.abstractmethod
    def method_to_implement(self, input):
        return

Preferred:

import abc

class Vehicle:
    __metaclass__ = abc.ABCMeta

    @abc.abstractmethod
    def method_to_implement(self, input):
        raise NotImplementedError