example.py:
'''
demo too many ancestors
'''
from flask_security.forms import RegisterForm
from wtforms.fields import TextField
class ExtendedRegisterForm(RegisterForm):
'''An extended register form'''
name = TextField('Name', [])
当我运行pylint时:
$ pylint -r n example.py
************* Module example
R: 7, 0: Too many ancestors (10/7) (too-many-ancestors)
这是什么意思,我该如何解决?
最佳答案
问题是您从一个拥有太多祖先的类继承:RegisterForm。在您的情况下,除了停止使用它(可能不是一种选择)之外,您无法对此做很多事情。因此,您可能要为此类禁用此消息,例如:
class ExtendedRegisterForm(RegisterForm): # pylint: disable=too-many-ancestors