Skip to main content
 首页 » 编程设计

python之"E1101"- "Class"的实例没有 "method"成员

2025年04月02日13del

我的类(class)是这样组织的:

class One: 
    def funcOne(self): 
        doSomething() 
 
class Two(One): 
    def funcTwo(self): 
        self.funcOne() 

当我运行它时,它起作用了,Python 的继承模型允许 Two 能够调用 funcOne。

但是,运行 pylint 给我错误:

[E1101 (no-member), myscript] Instance of 'Two' has no 'funcOne' member 

我已经看过 another question on the site ,但该问题涉及变量,唯一提出的解决方案是将它们放入字典中,而方法无法做到这一点。

如何让 pylint 识别继承行为?


编辑:我正在运行 pylint 1.1.0,它太旧了,也许这就是原因?

请您参考如下方法:

事实证明,我的 pylint 版本已经严重过时了。我正在运行版本 1.1.0,并更新到最新版本 1.6.4,警告消失了!

我认为这是 pylint 中的一个错误,已在不同版本之间修复