mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-31 04:07:30 +07:00
A class containing at least one method declared with `abstractmethod` decorator that hasn’t been overridden yet cannot be instantiated. Also report instantiation of classes that directly inherit ABC or have metaclass set to ABCMeta. GitOrigin-RevId: 55cb4dc90c55ddc63991a4c3f6b50b4e34a3b4bd
34 lines
859 B
Python
34 lines
859 B
Python
from abc import abstractmethod, ABCMeta
|
|
|
|
|
|
class AbstractClassA(metaclass=ABCMeta):
|
|
@abstractmethod
|
|
def foo(self): ...
|
|
|
|
@abstractmethod
|
|
def bar(self): ...
|
|
|
|
|
|
a = <warning descr="Cannot instantiate abstract class 'AbstractClassA'">AbstractClassA()</warning>
|
|
|
|
|
|
class <weak_warning descr="Class AbstractClassB must implement all abstract methods">AbstractClassB</weak_warning>(AbstractClassA):
|
|
...
|
|
|
|
|
|
b = <warning descr="Cannot instantiate abstract class 'AbstractClassB'">AbstractClassB()</warning>
|
|
|
|
|
|
class <weak_warning descr="Class AbstractClassC must implement all abstract methods">AbstractClassC</weak_warning>(AbstractClassB):
|
|
def foo(self): ...
|
|
|
|
|
|
c = <warning descr="Cannot instantiate abstract class 'AbstractClassC'">AbstractClassC()</warning>
|
|
|
|
|
|
class ConcreteClassC(AbstractClassC):
|
|
def bar(self): ...
|
|
|
|
|
|
cc = ConcreteClassC()
|