Skip to content

Commit 70bc54b

Browse files
committed
Suppress invalid-name for wsgi application. Fix #77
1 parent 3d85a4d commit 70bc54b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

pylint_django/augmentations/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,12 @@ def wrap_func(*args, **kwargs):
700700
return wrap_func
701701

702702

703+
def is_wsgi_application(node):
704+
frame = node.frame()
705+
return node.name == 'application' and isinstance(frame, Module) and \
706+
(frame.name == 'wsgi' or frame.path.endswith('wsgi.py') or frame.file.endswith('wsgi.py'))
707+
708+
703709
# The names of some visit functions changed in this commit:
704710
# https://bitbucket.org/logilab/pylint/commits/c94ee95abaa5737f13b91626fe321150c0ddd140
705711

@@ -822,3 +828,6 @@ def apply_augmentations(linter):
822828

823829
# supress not-an-iterable for model_utils.managers. See #117
824830
suppress_message(linter, IterableChecker._check_iterable, 'not-an-iterable', is_model_manager)
831+
832+
# wsgi.py
833+
suppress_message(linter, _visit_assignname(NameChecker), 'invalid-name', is_wsgi_application)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Standard WSGI config created by django-admin startproject.
3+
4+
Used to verify pylint_django doesn't produce invalid-name for
5+
the application variable. See:
6+
https://github.com/PyCQA/pylint-django/issues/77
7+
"""
8+
9+
import os
10+
11+
from django.core.wsgi import get_wsgi_application
12+
13+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproj.settings")
14+
15+
application = get_wsgi_application()

0 commit comments

Comments
 (0)