Pylint W0223:方法......在类中是抽象的......但没有被覆盖 [英] Pylint W0223: Method ... is abstract in class ... but is not overridden

查看:53
本文介绍了Pylint W0223:方法......在类中是抽象的......但没有被覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Pylint 为抽象类的子类生成此错误,即使这些子类本身没有实例化并且方法在具体子类中被覆盖.为什么 Pylint 认为我的抽象子类是具体的?如何在不拿出锤子并在 rc 文件中完全禁用它的情况下关闭此警告?

Pylint generates this error for subclasses of an abstract class, even when those subclasses are not themselves instantiated and the methods are overridden in the concrete subclasses. Why does Pylint think my abstract subclasses are intended to be concrete? How can I shut up this warning without getting out the hammer and disabling it altogether in the rc file?

推荐答案

出于某种原因,pylint 认为该类不是抽象的(当前检测是通过检查引发 NotImplementedError 的方法来完成的).在模块(仅在此模块中禁用)或类(仅在此类中)的顶部添加类似 #pylint: disable=W0223 的注释,应该可以解决问题.

For some reason pylint think the class isn't abstract (currenly detection is done by checking for method which raise NotImplementedError). Adding a comment like #pylint: disable=W0223 at the top of the module (for disabling only in this module) or class (only in this class), should do the trick.

这篇关于Pylint W0223:方法......在类中是抽象的......但没有被覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆