【发布时间】:2014-03-06 20:17:53
【问题描述】:
在 Python 3 中,我有以下代码:
class A:
def __init__(self):
pass
class B(A):
def __init__(self):
super().__init__()
这会产生 Pylint 警告:
- 定义了旧式类。 (旧式)
- 在旧样式类上使用 super(super-on-old-class)
据我了解,在 Python 3 中不再存在老式类,这段代码是可以的。
即使我在这段代码中明确使用新式类
class A(object):
def __init__(self):
pass
class B(A):
def __init__(self):
super().__init__()
由于在 Python 3 中调用父构造函数的语法不同,我收到 Pylint 警告:
- super() 缺少参数(缺少超级参数)
那么,我如何告诉 Pylint 我要检查 Python 3 代码以避免这些消息(不禁用 Pylint 检查)?
【问题讨论】:
标签: python inheritance python-3.x constructor pylint