machinalis / mypy-django

PEP-484 type hints bindings for the Django web framework
BSD 3-Clause "New" or "Revised" License
223 stars 23 forks source link

django.core.exceptions.ImproperlyConfigured: django-configurations settings importer wasn't correctly installed. #13

Open Niedzwiedzw opened 3 years ago

Niedzwiedzw commented 3 years ago

Bug Report

when trying to run "mypy" on my company's existing codebase I'm getting an error as follows:

root@826a40544ab8:/app/wwau/wwau# mypy --config-file=./setup.cfg ./wwau/settings.py 
Error constructing plugin instance of NewSemanalDjangoPlugin

Traceback (most recent call last):
  File "/usr/local/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "/usr/local/lib/python3.6/site-packages/mypy/__main__.py", line 8, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "mypy/main.py", line 90, in main
  File "mypy/build.py", line 180, in build
  File "mypy/build.py", line 229, in _build
  File "mypy/build.py", line 472, in load_plugins
  File "mypy/build.py", line 450, in load_plugins_from_config
  File "/usr/local/lib/python3.6/site-packages/mypy_django_plugin/main.py", line 100, in __init__
    self.django_context = DjangoContext(django_settings_module)
  File "/usr/local/lib/python3.6/site-packages/mypy_django_plugin/django/context.py", line 88, in __init__
    apps, settings = initialize_django(self.django_settings_module)
  File "/usr/local/lib/python3.6/site-packages/mypy_django_plugin/django/context.py", line 70, in initialize_django
    settings._setup()
  File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/wwau/wwau/wwau/settings.py", line 5, in <module>
    from common_settings import CommonBase, CommonLocal, CommonCI, CommonServer, VerboseLoggingMixin
  File "/app/shared/common_settings.py", line 17, in <module>
    class CommonBase(Configuration):
  File "/usr/local/lib/python3.6/site-packages/configurations/base.py", line 28, in __new__
    raise ImproperlyConfigured(install_failure)
django.core.exceptions.ImproperlyConfigured: django-configurations settings importer wasn't correctly installed. Please use one of the starter functions to install it as mentioned in the docs: https://django-configurations.readthedocs.io/

To Reproduce

Unable to reproduce in a similar django project sadly.

Expected Behavior

Just like in the other project - I'd like to see the mypy type errors in the console.

Actual Behavior

as above

Your Environment

[mypy.plugins.django-stubs] django_settings_module = "wwau.settings"