https://pantsbuild.org/ logo
#general
Title
# general
t

tall-plastic-15186

12/21/2022, 5:51 PM
Hi folks, encountering an issue with mypy with django stubs. So
./pants check ::
works as expected and we're able to see the typing errors across all files, however, if we run
./pants check <a specific file>
it's not able to find the settings module:
Copy code
Error constructing plugin instance of NewSemanalDjangoPlugin


Traceback (most recent call last):
  File "/tmp/pants-sandbox-sx8jrg/.cache/pex_root/venvs/452b1bd48fc9bdd09defe81a4d4ed2dfe7aa21c1/acab3aafcd0b37dc1f526605bd765ad366d418c4/pex", line 246, in <module>
    sys.exit(func())
  File "/home/irsoc/.cache/pants/named_caches/pex_root/venvs/s/f8ab7191/venv/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
  File "mypy/main.py", line 95, in main
  File "mypy/main.py", line 174, in run_build
  File "mypy/build.py", line 193, in build
  File "mypy/build.py", line 248, in _build
  File "mypy/build.py", line 507, in load_plugins
  File "mypy/build.py", line 488, in load_plugins_from_config
  File "/home/irsoc/.cache/pants/named_caches/pex_root/venvs/s/f8ab7191/venv/lib/python3.10/site-packages/mypy_django_plugin/main.py", line 73, in __init__
    self.django_context = DjangoContext(self.plugin_config.django_settings_module)
  File "/home/irsoc/.cache/pants/named_caches/pex_root/venvs/s/f8ab7191/venv/lib/python3.10/site-packages/mypy_django_plugin/django/context.py", line 83, in __init__
    apps, settings = initialize_django(self.django_settings_module)
  File "/home/irsoc/.cache/pants/named_caches/pex_root/venvs/s/f8ab7191/venv/lib/python3.10/site-packages/mypy_django_plugin/django/context.py", line 65, in initialize_django
    settings._setup()  # type: ignore
  File "/home/irsoc/.cache/pants/named_caches/pex_root/venvs/s/f8ab7191/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 79, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/irsoc/.cache/pants/named_caches/pex_root/venvs/s/f8ab7191/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 190, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/home/irsoc/.pyenv/versions/3.10.9/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'mymodule'
7 Views