2
2
3
3
import astroid
4
4
from pylint .checkers import BaseChecker
5
- from pylint .checkers .utils import check_messages
6
- from pylint .interfaces import IAstroidChecker
7
5
8
6
from pylint_django .__pkginfo__ import BASE_ID
7
+ from pylint_django .compat import check_messages
9
8
from pylint_django .transforms import foreignkey
10
9
11
10
@@ -27,8 +26,6 @@ class ForeignKeyStringsChecker(BaseChecker):
27
26
Some basic default settings were used, however this will lead to less accurate linting.
28
27
Consider passing in an explicit Django configuration file to match your project to improve accuracy."""
29
28
30
- __implements__ = (IAstroidChecker ,)
31
-
32
29
name = "Django foreign keys referenced by strings"
33
30
34
31
options = (
@@ -95,7 +92,12 @@ def open(self):
95
92
# this means that Django wasn't able to configure itself using some defaults
96
93
# provided (likely in a DJANGO_SETTINGS_MODULE environment variable)
97
94
# so see if the user has specified a pylint option
98
- if self .config .django_settings_module is None :
95
+ if hasattr (self , "linter" ):
96
+ django_settings_module = self .linter .config .django_settings_module
97
+ else :
98
+ django_settings_module = self .config .django_settings_module
99
+
100
+ if django_settings_module is None :
99
101
# we will warn the user that they haven't actually configured Django themselves
100
102
self ._raise_warning = True
101
103
# but use django defaults then...
@@ -108,7 +110,7 @@ def open(self):
108
110
try :
109
111
from django .conf import Settings , settings # pylint: disable=import-outside-toplevel
110
112
111
- settings .configure (Settings (self . config . django_settings_module ))
113
+ settings .configure (Settings (django_settings_module ))
112
114
django .setup ()
113
115
except ImportError :
114
116
# we could not find the provided settings module...
0 commit comments