Search code examples
pythonpylint

Understanding "Too many ancestors" from pylint


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?


Solution

  • From documentation here: https://pylint.readthedocs.io/en/stable/technical_reference/features.html

    too-many-ancestors (R0901): Too many ancestors (%s/%s) Used when class has too many parent classes, try to reduce this to get a simpler (and so easier to use) class.