Skip to content

Latest commit

 

History

History
46 lines (28 loc) · 869 Bytes

E0110.md

File metadata and controls

46 lines (28 loc) · 869 Bytes

E0110 (abstract-class-instantiated)

❌ Problematic code:

from abc import ABC, abstractmethod


class BaseClass(ABC):
    @abstractmethod
    def get_something(self):
        pass


base = BaseClass()

✔️ Correct code:

from abc import ABC, abstractmethod


class BaseClass(ABC):
    @abstractmethod
    def get_something(self):
        pass


class Foo(BaseClass):
    def get_something(self):
        pass


foo = Foo()

Rationale:

Used when an abstract class with abc.ABCMeta or abc.ABC as metaclass has abstract methods and is instantiated.

Related resources: