From 9658366d723b6008658f63f17d570480514b1126 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 3 May 2024 00:12:47 -0400 Subject: [PATCH] Fix mypy for django-configurations still have a lot of bad typing, but at least it runs again --- cmsmanage/mypy_django_configurations_plugin.py | 12 ++++++++++++ pyproject.toml | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 cmsmanage/mypy_django_configurations_plugin.py diff --git a/cmsmanage/mypy_django_configurations_plugin.py b/cmsmanage/mypy_django_configurations_plugin.py new file mode 100644 index 0000000..b52779c --- /dev/null +++ b/cmsmanage/mypy_django_configurations_plugin.py @@ -0,0 +1,12 @@ +# https://github.com/typeddjango/django-stubs/pull/180#issuecomment-820062352 +import os + +from configurations import importer +from mypy_django_plugin import main + + +def plugin(version): + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cmsmanage.settings") + os.environ.setdefault("DJANGO_CONFIGURATION", "Dev") + importer.install() + return main.plugin(version) diff --git a/pyproject.toml b/pyproject.toml index fd4dabe..e321e93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,13 +90,14 @@ indent_size = 2 [tool.mypy] plugins = [ + "./cmsmanage/mypy_django_configurations_plugin.py", "mypy_django_plugin.main", "mypy_drf_plugin.main", ] [tool.django-stubs] -django_settings_module = "cmsmanage.settings.dev" - +django_settings_module = "cmsmanage.settings" +strict_settings = false [[tool.pdm.source]] url = "https://pypi.org/simple"