Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 4, 2022
1 parent 8196b1f commit ec3bcf6
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions pylint_django/checkers/foreign_key_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,23 @@ def open(self):
try:
import django # pylint: disable=import-outside-toplevel

if (
os.environ.get("DJANGO_SETTINGS_MODULE") is None
or os.environ.get("DJANGO_CONFIGURATION") is None
):
if os.environ.get("DJANGO_SETTINGS_MODULE") is None or os.environ.get("DJANGO_CONFIGURATION") is None:
try:
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE",
os.environ.get("DJANGO_SETTINGS_MODULE")
or self.config.django_settings_module,
os.environ.get("DJANGO_SETTINGS_MODULE") or self.config.django_settings_module,
)
os.environ.setdefault(
"DJANGO_CONFIGURATION",
os.environ.get("DJANGO_CONFIGURATION")
or self.config.django_configuration,
os.environ.get("DJANGO_CONFIGURATION") or self.config.django_configuration,
)
except TypeError as ex:
missing_module = ""
if self.config.django_settings_module is None:
missing_module = "DJANGO_SETTINGS_MODULE"
else:
missing_module = "DJANGO_CONFIGURATION"
raise RuntimeError(
f"{missing_module} required to initialize Django project settings"
) from ex
raise RuntimeError(f"{missing_module} required to initialize Django project settings") from ex
importer.install()

django.setup()
Expand Down

0 comments on commit ec3bcf6

Please sign in to comment.