Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress too-many-ancestors for more class-based views #261

Open
rik opened this issue Mar 19, 2020 · 2 comments
Open

Suppress too-many-ancestors for more class-based views #261

rik opened this issue Mar 19, 2020 · 2 comments

Comments

@rik
Copy link

rik commented Mar 19, 2020

#254 suppressed too-many-ancestors for BaseDetailView. It would be nice to suppress this message for other class-based views

Is there any reason why this wasn't done for all descendants of django.views.generic.View?

@atodorov
Copy link
Contributor

Is there any reason why this wasn't done for all descendants of django.views.generic.View?

@rik I don't remember what was the reasoning at the time.

I think I was trying to make it work but didn't manage to convince pylint internals to suppress this error for all descendants of django.views.generic.View. However that doesn't sound very accurate (at least without experimenting).

Or it could have been that I simply didn't have any direct descendants of View in the project I was running pylint-django against.

In any case the change appears to be very small so you can experiment with it. If it works we'll happily accept a pull request, especially if you have tests in it.

NOTE: the View class can be imported in projects both as django.views.generic.View and django.views.View which I think confuses the inference machinery.

@imomaliev
Copy link
Contributor

Maybe we should add a suggested value for max-parents to avoid this error in most cases. For example I am using django-import-export in my current project and I am getting R0901: Too many ancestors (10/7) (too-many-ancestors) with only one level of inheritance from from import_export.admin import ImportExportModelAdmin. I think max-parents=14 will be good enough for most cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants