Python

Python

Made by DeepSource

Abstract class instantiated PYL-E0110

Bug risk
Critical

An abstract class with abc.ABCMeta as metaclass has abstract methods and is instantiated. This will result in a TypeError as Python can't instantiate abstract class with abstract methods.

Bad practice

class BadClass(metaclass=abc.ABCMeta):
    @abc.abstractmethod
    def test(self):
        '''Do nothing.'''

On trying to instantiate this BadClass, Python will raise: TypeError: Can't instantiate abstract class BadClass with abstract methods test.

Recommended

class BadClass(metaclass=abc.ABCMeta):

    def test(self):
        '''Do nothing.'''