mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-05 02:55:18 +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. (cherry picked from commit 55cb4dc90c55ddc63991a4c3f6b50b4e34a3b4bd) GitOrigin-RevId: b37ea24490dc5ce7dcce87adf21aa6fe31e0e9dc
17 lines
297 B
Python
17 lines
297 B
Python
from abc import ABCMeta, abstractmethod
|
|
|
|
|
|
class AbstractClass(metaclass=ABCMeta):
|
|
@abstractmethod
|
|
def foo(self):
|
|
...
|
|
|
|
|
|
def bar(cls: type[AbstractClass]):
|
|
return cls().foo()
|
|
|
|
|
|
AC = AbstractClass
|
|
|
|
<warning descr="Cannot instantiate abstract class 'AbstractClass'">AC()</warning>
|