【发布时间】:2023-03-17 04:22:01
【问题描述】:
所以我在 Python 中有一个基于 Python 2.7 文档创建的简单自定义错误类:
class InvalidTeamError(Exception):
def __init__(self, message='This user belongs to a different team'):
self.message = message
这给了我在 PyLint 中的警告 W0231: __init__ method from base class %r is not called,所以我去查找它并得到“需要解释”的非常有用的描述。我通常会忽略这个错误,但我注意到在线的大量代码在自定义错误类的 init 方法的开头包含对 super 的调用,所以我的问题是:这样做真的有用吗目的还是只是人们试图安抚虚假的 pylint 警告?
【问题讨论】:
标签: python python-2.7 exception pylint