File: backport-pylint-3.x-fixes.patch

package info (click to toggle)
pylint-django 2.0.13-5%2Bdeb13u1
  • links: PTS, VCS
  • area: main
  • in suites: trixie-proposed-updates
  • size: 704 kB
  • sloc: python: 1,808; sh: 12; makefile: 5
file content (158 lines) | stat: -rw-r--r-- 6,183 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
From: Mathias Gibbens <gibmat@debian.org>
Description: Backport changes for pylint 3.x
Origin: https://github.com/pylint-dev/pylint-django/commit/3b760edfb42233174478df097598486db84132aa
diff --git a/pylint_django/checkers/db_performance.py b/pylint_django/checkers/db_performance.py
index f401c61..ad85677 100644
--- a/pylint_django/checkers/db_performance.py
+++ b/pylint_django/checkers/db_performance.py
@@ -88,7 +88,7 @@ class NewDbFieldWithDefaultChecker(checkers.BaseChecker):
             if node not in self._possible_offences[module]:
                 self._possible_offences[module].append(node)
 
-    @utils.check_messages('new-db-field-with-default')
+    @check_messages('new-db-field-with-default')
     def close(self):
         def _path(node):
             return node.path
diff --git a/pylint_django/checkers/django_installed.py b/pylint_django/checkers/django_installed.py
index 1a51c70..45511c7 100644
--- a/pylint_django/checkers/django_installed.py
+++ b/pylint_django/checkers/django_installed.py
@@ -1,7 +1,7 @@
 from __future__ import absolute_import
 from pylint.checkers import BaseChecker
-from pylint.checkers.utils import check_messages
 from pylint_django.__pkginfo__ import BASE_ID
+from pylint_django.compat import check_messages
 
 
 class DjangoInstalledChecker(BaseChecker):
diff --git a/pylint_django/checkers/forms.py b/pylint_django/checkers/forms.py
index 7605ec3..3fe8ab4 100644
--- a/pylint_django/checkers/forms.py
+++ b/pylint_django/checkers/forms.py
@@ -1,11 +1,10 @@
 """Models."""
 from astroid.nodes import Assign, ClassDef
 
-from pylint.interfaces import IAstroidChecker
-from pylint.checkers.utils import check_messages
 from pylint.checkers import BaseChecker
 
 from pylint_django.__pkginfo__ import BASE_ID
+from pylint_django.compat import check_messages
 from pylint_django.utils import node_is_subclass
 
 
@@ -18,7 +17,6 @@ def _get_child_meta(node):
 
 class FormChecker(BaseChecker):
     """Django model checker."""
-    __implements__ = IAstroidChecker
 
     name = 'django-form-checker'
     msgs = {
diff --git a/pylint_django/checkers/json_response.py b/pylint_django/checkers/json_response.py
index 922f55f..61ae90c 100644
--- a/pylint_django/checkers/json_response.py
+++ b/pylint_django/checkers/json_response.py
@@ -8,9 +8,10 @@ Various suggestions about JSON http responses
 
 import astroid
 
-from pylint import interfaces, checkers
-from pylint.checkers import utils
+from pylint import checkers
+
 from pylint_django.__pkginfo__ import BASE_ID
+from pylint_django.compat import check_messages
 
 
 class JsonResponseChecker(checkers.BaseChecker):
@@ -19,8 +20,6 @@ class JsonResponseChecker(checkers.BaseChecker):
     JSON data!
     """
 
-    __implements__ = (interfaces.IAstroidChecker,)
-
     # configuration section name
     name = 'json-response-checker'
     msgs = {'R%s01' % BASE_ID: ("Instead of HttpResponse(json.dumps(data)) use JsonResponse(data)",
@@ -35,9 +34,9 @@ class JsonResponseChecker(checkers.BaseChecker):
                                 'This is either redundant or the content_type is not JSON '
                                 'which is probably an error.')}
 
-    @utils.check_messages('http-response-with-json-dumps',
-                          'http-response-with-content-type-json',
-                          'redundant-content-type-for-json-response')
+    @check_messages('http-response-with-json-dumps',
+                    'http-response-with-content-type-json',
+                    'redundant-content-type-for-json-response')
     def visit_call(self, node):
         if (node.func.as_string().endswith('HttpResponse') and node.args
                 and isinstance(node.args[0], astroid.Call)
diff --git a/pylint_django/checkers/models.py b/pylint_django/checkers/models.py
index d229a6a..b3fd04e 100644
--- a/pylint_django/checkers/models.py
+++ b/pylint_django/checkers/models.py
@@ -3,11 +3,10 @@ from astroid import Const
 from astroid.nodes import Assign
 from astroid.nodes import ClassDef, FunctionDef, AssignName
 
-from pylint.interfaces import IAstroidChecker
-from pylint.checkers.utils import check_messages
 from pylint.checkers import BaseChecker
 
 from pylint_django.__pkginfo__ import BASE_ID
+from pylint_django.compat import check_messages
 from pylint_django.utils import node_is_subclass, PY3
 
 
@@ -70,7 +69,6 @@ def _is_unicode_or_str_in_python_2_compatibility(method):
 
 class ModelChecker(BaseChecker):
     """Django model checker."""
-    __implements__ = IAstroidChecker
 
     name = 'django-model-checker'
     msgs = MESSAGES
diff --git a/pylint_django/compat.py b/pylint_django/compat.py
index 9b607bc..2393ddd 100644
--- a/pylint_django/compat.py
+++ b/pylint_django/compat.py
@@ -22,6 +22,11 @@ except ImportError:
     except ImportError:
         from astroid.util import Uninferable
 
+try:
+    from pylint.checkers.utils import check_messages
+except (ImportError, ModuleNotFoundError):
+    from pylint.checkers.utils import only_required_for_messages as check_messages
+
 import pylint
 
 # pylint before version 2.3 does not support load_configuration() hook.
diff --git a/pylint_django/plugin.py b/pylint_django/plugin.py
index 194f80d..1753f74 100644
--- a/pylint_django/plugin.py
+++ b/pylint_django/plugin.py
@@ -1,7 +1,4 @@
 """Common Django module."""
-from pylint.checkers.base import NameChecker
-from pylint_plugin_utils import get_checker
-
 from pylint_django.checkers import register_checkers
 
 # we want to import the transforms to make sure they get added to the astroid manager,
@@ -14,9 +11,8 @@ def load_configuration(linter):
     """
     Amend existing checker config.
     """
-    name_checker = get_checker(linter, NameChecker)
-    name_checker.config.good_names += ('qs', 'urlpatterns', 'register', 'app_name',
-                                       'handler400', 'handler403', 'handler404', 'handler500')
+    linter.config.good_names += ('qs', 'urlpatterns', 'register', 'app_name',
+                                 'handler400', 'handler403', 'handler404', 'handler500')
 
     # we don't care about South migrations
     linter.config.black_list += ('migrations', 'south_migrations')