mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-31 14:00:54 +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
30 lines
533 B
Python
30 lines
533 B
Python
from abc import ABC, ABCMeta
|
|
|
|
|
|
class AbstractClass1(ABC):
|
|
def foo(self) -> None: ...
|
|
|
|
|
|
c1 = <weak_warning descr="Cannot instantiate abstract class 'AbstractClass1'">AbstractClass1()</weak_warning>
|
|
|
|
|
|
class ConcreteClass1(AbstractClass1):
|
|
...
|
|
|
|
|
|
cc1 = ConcreteClass1()
|
|
|
|
|
|
class AbstractClass2(metaclass=ABCMeta):
|
|
...
|
|
|
|
|
|
c2 = <weak_warning descr="Cannot instantiate abstract class 'AbstractClass2'">AbstractClass2()</weak_warning>
|
|
|
|
|
|
class ConcreteClass2(AbstractClass2):
|
|
def bar(self) -> None: ...
|
|
|
|
|
|
cc2 = ConcreteClass2()
|