Skip to content

Commit 0a9cb12

Browse files
atodorovcarlio
authored andcommitted
Don't crash if Django isn't installed
DjangoInstalledChecker will catch the condition and inform the user, but we should not crash before that checker gets executed.
1 parent 3bc44a6 commit 0a9cb12

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pylint_django/checkers/foreign_key_strings.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,12 @@ def open(self):
7878
# must wait until some module is inspected to be able to raise... so that
7979
# state is stashed in this property.
8080

81-
from django.core.exceptions import ( # pylint: disable=import-outside-toplevel
82-
ImproperlyConfigured,
83-
)
81+
try:
82+
from django.core.exceptions import ( # pylint: disable=import-outside-toplevel
83+
ImproperlyConfigured,
84+
)
85+
except ModuleNotFoundError:
86+
return
8487

8588
try:
8689
import django # pylint: disable=import-outside-toplevel

0 commit comments

Comments
 (0)