22
33import astroid
44from pylint .checkers import BaseChecker
5- from pylint .checkers .utils import check_messages
6- from pylint .interfaces import IAstroidChecker
75
86from pylint_django .__pkginfo__ import BASE_ID
7+ from pylint_django .compat import check_messages
98from pylint_django .transforms import foreignkey
109
1110
@@ -27,8 +26,6 @@ class ForeignKeyStringsChecker(BaseChecker):
2726Some basic default settings were used, however this will lead to less accurate linting.
2827Consider passing in an explicit Django configuration file to match your project to improve accuracy."""
2928
30- __implements__ = (IAstroidChecker ,)
31-
3229 name = "Django foreign keys referenced by strings"
3330
3431 options = (
@@ -95,7 +92,12 @@ def open(self):
9592 # this means that Django wasn't able to configure itself using some defaults
9693 # provided (likely in a DJANGO_SETTINGS_MODULE environment variable)
9794 # 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 :
99101 # we will warn the user that they haven't actually configured Django themselves
100102 self ._raise_warning = True
101103 # but use django defaults then...
@@ -108,7 +110,7 @@ def open(self):
108110 try :
109111 from django .conf import Settings , settings # pylint: disable=import-outside-toplevel
110112
111- settings .configure (Settings (self . config . django_settings_module ))
113+ settings .configure (Settings (django_settings_module ))
112114 django .setup ()
113115 except ImportError :
114116 # we could not find the provided settings module...
0 commit comments