python - 抽象类的错误 "__init__ method from base class is not called"

标签 python pylint

我有

class A(object):
    def __init__ (self): raise NotImplementedError("A")

class B(A):
    def __init__ (self):
        ....

和 pylint 说

__init__ method from base class 'A' is not called

很明显,我不想做

super(B, self).__init__()
  • 那我该怎么办?

(我尝试了 abc 并得到了

Undefined variable 'abstractmethod'

来自 pylint,因此这也不是一个选项)。

最佳答案

忽略pylint。它只是一个不考虑抽象类的程序。相信你比它更聪明。 Pylint 是护膝,而不是拐杖。

关于python - 抽象类的错误 "__init__ method from base class is not called",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25072363/

相关文章:

python - 按行和列写入 csv

python - Plotly Python - 更改表格的字体

python - 当两个异步任务访问同一个可等待对象时是否安全?

python - 为什么在pylint中bar被列入黑名单

python - 如何找到已安装的 pandas 版本

python - 使 Python-Telegram-Bot 持久化

pylint - 如何在 Pylint 中禁用 "No space allowed around keyword argument assignment"?

python - VS Code pylint(import-error) "Unable to import"来自自定义目录的子模块

python - 避免在 python 脚本名称中出现关于破折号的 pylint 警告

python - 如何使 pylint 不提示全局 argparse.Namespace?