Understanding "Too many ancestors" from pylint

jon picture jon · Apr 3, 2014 · Viewed 13.2k times · Source

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', [])

When I run pylint:

$ pylint -r n example.py
************* Module example
R:  7, 0: Too many ancestors (10/7) (too-many-ancestors)

What does this mean and how can I fix it?

Answer

sthenault picture sthenault · Apr 7, 2014

The problem is that you inherit from a class which has itself (too) many ancestors: RegisterForm. In your case, you can't do a lot about this, beside stopping using it which is probably not an option. So you may want to disable this message for this class, eg:

class ExtendedRegisterForm(RegisterForm): # pylint: disable=too-many-ancestors