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 ModelViewSets #365

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Expand Up @@ -20,3 +20,4 @@
* [naquiroz](https://github.com/naquiroz)
* [john-sandall](https://github.com/john-sandall)
* [dineshtrivedi](https://github.com/dineshtrivedi)
* [jhhayashi](https://github.com/jhhayashi)
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -106,7 +106,7 @@ This plugin is disabled by default! To enable it::
Contributing
------------

Please feel free to add your name to the ``CONTRIBUTORS.rst`` file if you want to
Please feel free to add your name to the ``CONTRIBUTORS.md`` file if you want to
be credited when pull requests get merged. You can also add to the
``CHANGELOG.rst`` file if you wish, although we'll also do that when merging.

Expand Down
8 changes: 8 additions & 0 deletions pylint_django/augmentations/__init__.py
Expand Up @@ -895,6 +895,14 @@ def apply_augmentations(linter):
IsClass("django.views.generic.edit.ProcessFormView"),
)

# ModelViewSet also suffers from too many ancestors
suppress_message(
linter,
MisdesignChecker.visit_classdef,
"too-many-ancestors",
IsClass("rest_framework.viewsets.ModelViewSet"),
)

# model forms have no __init__ method anywhere in their bases
suppress_message(
linter,
Expand Down
10 changes: 10 additions & 0 deletions pylint_django/tests/input/external_drf_noerror_modelviewset.py
@@ -0,0 +1,10 @@
"""
Checks that Pylint does not complain about DRF viewsets
"""
# pylint: disable=C0111,W5101,use-symbolic-message-instead,import-error,too-few-public-methods

from rest_framework import viewsets


class TestModelViewsetSubclass(viewsets.ModelViewset):
pass
7 changes: 4 additions & 3 deletions setup.py
Expand Up @@ -24,13 +24,14 @@
extras_require={
"with_django": ["Django"],
"for_tests": [
"coverage",
"django_tables2",
"django-tastypie",
"djangorestframework",
"factory-boy",
"coverage",
"pylint>=2.13",
"pytest",
"wheel",
"django-tastypie",
"pylint>=2.13",
],
},
license="GPLv2",
Expand Down