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?
python pylint
add a comment |
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?
python pylint
Whether this advice makes any sense is highly context-specific... In this specific case, I'd say there's nothing to fix. In general, always take the output of these style-checkers with a grain of salt.
– Matteo Italia
Apr 3 '14 at 11:26
add a comment |
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?
python 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?
python pylint
python pylint
edited Apr 3 '14 at 11:18
DzinX
31.8k85177
31.8k85177
asked Apr 3 '14 at 10:10
jonjon
3,47831732
3,47831732
Whether this advice makes any sense is highly context-specific... In this specific case, I'd say there's nothing to fix. In general, always take the output of these style-checkers with a grain of salt.
– Matteo Italia
Apr 3 '14 at 11:26
add a comment |
Whether this advice makes any sense is highly context-specific... In this specific case, I'd say there's nothing to fix. In general, always take the output of these style-checkers with a grain of salt.
– Matteo Italia
Apr 3 '14 at 11:26
Whether this advice makes any sense is highly context-specific... In this specific case, I'd say there's nothing to fix. In general, always take the output of these style-checkers with a grain of salt.
– Matteo Italia
Apr 3 '14 at 11:26
Whether this advice makes any sense is highly context-specific... In this specific case, I'd say there's nothing to fix. In general, always take the output of these style-checkers with a grain of salt.
– Matteo Italia
Apr 3 '14 at 11:26
add a comment |
4 Answers
4
active
oldest
votes
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
add a comment |
From documentation here: http://docs.pylint.org/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.
add a comment |
In addition to the disabling directives in the source code, you can configure this through the --max-parents= commandline option. You can also specify this in the config file (.pylintrc):
[DESIGN]
max-parents=15
As you can see I set it to 15 as many classes in Django (my project), particularly its view classes, will have hierarchies that are deeper than the default 7.
prospector: error: unrecognized arguments: --max-parents=15
– andilabs
May 23 '17 at 8:57
I just verified that it works at my end -- both the command line option as well as the config file setting. What version of pylint are you using? Mine's 1.6.5, running on Python 2.7.6 code.
– Hari Mahadevan
May 24 '17 at 7:07
I just added django in uses section and didn't care more about too-many-ancestors.
– andilabs
May 24 '17 at 11:35
I suppose you sorted out your issues. However what you did is not clear to me. It'll be great if you can share the solution, time permitting of course. Tks.
– Hari Mahadevan
May 25 '17 at 8:10
add a comment |
basically Add to json or .pylintrc --max-parents='yourrequirednumber'
Note: --max-parents=7
is default
If using Visual Studio Code (VSC) you can easily override default config with adding
below code to settings.json
Go to --> UserSettings ctrl+,
(default shortcut) --> click ... (more actions) --> open settings.json --> Add to overwrite Default settings this code:
"python.linting.pydocstyleArgs": ["--max-parents=25"]
NOTE2:
if pylint_django is not installed:
$ pip install pylint-django
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22834392%2funderstanding-too-many-ancestors-from-pylint%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
add a comment |
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
add a comment |
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
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
answered Apr 7 '14 at 7:45
sthenaultsthenault
7,21432327
7,21432327
add a comment |
add a comment |
From documentation here: http://docs.pylint.org/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.
add a comment |
From documentation here: http://docs.pylint.org/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.
add a comment |
From documentation here: http://docs.pylint.org/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.
From documentation here: http://docs.pylint.org/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.
answered Apr 3 '14 at 10:13
jonjon
3,47831732
3,47831732
add a comment |
add a comment |
In addition to the disabling directives in the source code, you can configure this through the --max-parents= commandline option. You can also specify this in the config file (.pylintrc):
[DESIGN]
max-parents=15
As you can see I set it to 15 as many classes in Django (my project), particularly its view classes, will have hierarchies that are deeper than the default 7.
prospector: error: unrecognized arguments: --max-parents=15
– andilabs
May 23 '17 at 8:57
I just verified that it works at my end -- both the command line option as well as the config file setting. What version of pylint are you using? Mine's 1.6.5, running on Python 2.7.6 code.
– Hari Mahadevan
May 24 '17 at 7:07
I just added django in uses section and didn't care more about too-many-ancestors.
– andilabs
May 24 '17 at 11:35
I suppose you sorted out your issues. However what you did is not clear to me. It'll be great if you can share the solution, time permitting of course. Tks.
– Hari Mahadevan
May 25 '17 at 8:10
add a comment |
In addition to the disabling directives in the source code, you can configure this through the --max-parents= commandline option. You can also specify this in the config file (.pylintrc):
[DESIGN]
max-parents=15
As you can see I set it to 15 as many classes in Django (my project), particularly its view classes, will have hierarchies that are deeper than the default 7.
prospector: error: unrecognized arguments: --max-parents=15
– andilabs
May 23 '17 at 8:57
I just verified that it works at my end -- both the command line option as well as the config file setting. What version of pylint are you using? Mine's 1.6.5, running on Python 2.7.6 code.
– Hari Mahadevan
May 24 '17 at 7:07
I just added django in uses section and didn't care more about too-many-ancestors.
– andilabs
May 24 '17 at 11:35
I suppose you sorted out your issues. However what you did is not clear to me. It'll be great if you can share the solution, time permitting of course. Tks.
– Hari Mahadevan
May 25 '17 at 8:10
add a comment |
In addition to the disabling directives in the source code, you can configure this through the --max-parents= commandline option. You can also specify this in the config file (.pylintrc):
[DESIGN]
max-parents=15
As you can see I set it to 15 as many classes in Django (my project), particularly its view classes, will have hierarchies that are deeper than the default 7.
In addition to the disabling directives in the source code, you can configure this through the --max-parents= commandline option. You can also specify this in the config file (.pylintrc):
[DESIGN]
max-parents=15
As you can see I set it to 15 as many classes in Django (my project), particularly its view classes, will have hierarchies that are deeper than the default 7.
answered Mar 29 '17 at 10:04
Hari MahadevanHari Mahadevan
65159
65159
prospector: error: unrecognized arguments: --max-parents=15
– andilabs
May 23 '17 at 8:57
I just verified that it works at my end -- both the command line option as well as the config file setting. What version of pylint are you using? Mine's 1.6.5, running on Python 2.7.6 code.
– Hari Mahadevan
May 24 '17 at 7:07
I just added django in uses section and didn't care more about too-many-ancestors.
– andilabs
May 24 '17 at 11:35
I suppose you sorted out your issues. However what you did is not clear to me. It'll be great if you can share the solution, time permitting of course. Tks.
– Hari Mahadevan
May 25 '17 at 8:10
add a comment |
prospector: error: unrecognized arguments: --max-parents=15
– andilabs
May 23 '17 at 8:57
I just verified that it works at my end -- both the command line option as well as the config file setting. What version of pylint are you using? Mine's 1.6.5, running on Python 2.7.6 code.
– Hari Mahadevan
May 24 '17 at 7:07
I just added django in uses section and didn't care more about too-many-ancestors.
– andilabs
May 24 '17 at 11:35
I suppose you sorted out your issues. However what you did is not clear to me. It'll be great if you can share the solution, time permitting of course. Tks.
– Hari Mahadevan
May 25 '17 at 8:10
prospector: error: unrecognized arguments: --max-parents=15
– andilabs
May 23 '17 at 8:57
prospector: error: unrecognized arguments: --max-parents=15
– andilabs
May 23 '17 at 8:57
I just verified that it works at my end -- both the command line option as well as the config file setting. What version of pylint are you using? Mine's 1.6.5, running on Python 2.7.6 code.
– Hari Mahadevan
May 24 '17 at 7:07
I just verified that it works at my end -- both the command line option as well as the config file setting. What version of pylint are you using? Mine's 1.6.5, running on Python 2.7.6 code.
– Hari Mahadevan
May 24 '17 at 7:07
I just added django in uses section and didn't care more about too-many-ancestors.
– andilabs
May 24 '17 at 11:35
I just added django in uses section and didn't care more about too-many-ancestors.
– andilabs
May 24 '17 at 11:35
I suppose you sorted out your issues. However what you did is not clear to me. It'll be great if you can share the solution, time permitting of course. Tks.
– Hari Mahadevan
May 25 '17 at 8:10
I suppose you sorted out your issues. However what you did is not clear to me. It'll be great if you can share the solution, time permitting of course. Tks.
– Hari Mahadevan
May 25 '17 at 8:10
add a comment |
basically Add to json or .pylintrc --max-parents='yourrequirednumber'
Note: --max-parents=7
is default
If using Visual Studio Code (VSC) you can easily override default config with adding
below code to settings.json
Go to --> UserSettings ctrl+,
(default shortcut) --> click ... (more actions) --> open settings.json --> Add to overwrite Default settings this code:
"python.linting.pydocstyleArgs": ["--max-parents=25"]
NOTE2:
if pylint_django is not installed:
$ pip install pylint-django
add a comment |
basically Add to json or .pylintrc --max-parents='yourrequirednumber'
Note: --max-parents=7
is default
If using Visual Studio Code (VSC) you can easily override default config with adding
below code to settings.json
Go to --> UserSettings ctrl+,
(default shortcut) --> click ... (more actions) --> open settings.json --> Add to overwrite Default settings this code:
"python.linting.pydocstyleArgs": ["--max-parents=25"]
NOTE2:
if pylint_django is not installed:
$ pip install pylint-django
add a comment |
basically Add to json or .pylintrc --max-parents='yourrequirednumber'
Note: --max-parents=7
is default
If using Visual Studio Code (VSC) you can easily override default config with adding
below code to settings.json
Go to --> UserSettings ctrl+,
(default shortcut) --> click ... (more actions) --> open settings.json --> Add to overwrite Default settings this code:
"python.linting.pydocstyleArgs": ["--max-parents=25"]
NOTE2:
if pylint_django is not installed:
$ pip install pylint-django
basically Add to json or .pylintrc --max-parents='yourrequirednumber'
Note: --max-parents=7
is default
If using Visual Studio Code (VSC) you can easily override default config with adding
below code to settings.json
Go to --> UserSettings ctrl+,
(default shortcut) --> click ... (more actions) --> open settings.json --> Add to overwrite Default settings this code:
"python.linting.pydocstyleArgs": ["--max-parents=25"]
NOTE2:
if pylint_django is not installed:
$ pip install pylint-django
edited Jan 13 at 10:35
SylvainB
4,23021635
4,23021635
answered Nov 21 '18 at 11:07
JoehoeJoehoe
239
239
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22834392%2funderstanding-too-many-ancestors-from-pylint%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Whether this advice makes any sense is highly context-specific... In this specific case, I'd say there's nothing to fix. In general, always take the output of these style-checkers with a grain of salt.
– Matteo Italia
Apr 3 '14 at 11:26