pylint-dev / pylint-django

Pylint plugin for improving code analysis for when using Django
Other
591 stars 117 forks source link

Unnecessary warnings around `class Meta` for Django tables2 #367

Open addisonklinke opened 2 years ago

addisonklinke commented 2 years ago

Description

Take a boilerplate example from the Django Tables2 docs

import django_tables2 as tables
from .models import Person

class PersonTable(tables.Table):
    class Meta:
        model = Person
        template_name = "django_tables2/bootstrap.html"
        fields = ("name", )

Even with the pylint_django plugin, pylint raises the following complaints for the Meta class

However, other uses of the class Meta syntax do not trigger the same complaints (i.e. for Django's built-in forms/model, DRF's serializers, and Django filter's filtersets). This seems like a missing feature in the plugin to fully support Django Tables2

Environment

Pylint configuration

[MASTER]
load-plugins=pylint_django
ignore-paths=.*/migrations/*

[FORMAT]
max-line-length=120

# Accepted naming conventions
good-names=
    i,k,ex,_,  # Default pylint suggestions
    f,         # Used for `with open(...) as f`
    r,         # Requests response
    v,         # Dict values
    tb,        # Traceback
    df,        # Pandas dataframe

# Whitelist specific unittest method names
# Adapted from https://stackoverflow.com/a/13236488/7446465
method-rgx=[a-z_][a-z0-9_]{2,30}|setUp|tearDown$

[MESSAGES CONTROL]
disable=
    unspecified-encoding,
    logging-fstring-interpolation,

[MISCELLANEOUS]

# List of note tags to raise linter warnings on
# Remove TODO since it is used for future items that cannot be addressed immediately
# FIXME should be the preferred prefix for items that need to be completed before merging a PR
notes=FIXME

[TYPECHECK]
# Avoid raising no-member for packages/classes which dynamically generate them
generated-members=
    pandas.*,

[SIMILARITIES]
# Exclude imports from the similarity computation for duplicate-code
ignore-imports=yes

Output of pip freeze

asgiref==3.3.1
astroid==2.11.7
backcall==0.2.0
beautifulsoup4==4.10.0
boto3==1.24.24
botocore==1.27.24
certifi==2020.12.5
chardet==4.0.0
coverage==6.4.2
decorator==5.0.4
dill==0.3.5.1
Django==3.1.7
django-crispy-forms==1.11.2
django-filter==21.1
django-storages==1.12.3
django-tables2==2.4.1
djangorestframework==3.13.1
idna==2.10
ipython==7.22.0
ipython-genutils==0.2.0
isort==5.10.1
jedi==0.17.2
jmespath==1.0.1
lazy-object-proxy==1.7.1
lxml==4.8.0
mccabe==0.7.0
numpy==1.22.2
pandas==1.4.1
parso==0.7.1
pexpect==4.8.0
pickleshare==0.7.5
piexif==1.1.3
Pillow==9.2.0
platformdirs==2.5.2
prompt-toolkit==3.0.18
psycopg2-binary==2.8.6
ptyprocess==0.7.0
Pygments==2.8.1
pylint==2.14.5
pylint-django==2.5.3
pylint-plugin-utils==0.7
python-dateutil==2.8.2
pytz==2021.1
PyYAML==5.4.1
requests==2.25.1
s3transfer==0.6.0
selenium==3.141.0
six==1.16.0
soupsieve==2.3.1
sqlparse==0.4.1
tomli==2.0.1
tomlkit==0.11.1
traitlets==5.0.5
typing-extensions==4.3.0
urllib3==1.26.5
wcwidth==0.2.5
wrapt==1.14.1
qi55wyqu commented 1 year ago

I'm getting the same error message when subclassing django.contrib.admin.ModelAdmin