4

I've created a project using Django Cookiecutter, following the steps listed here: https://cookiecutter-django.readthedocs.io/en/latest/developing-locally.html

(from a project generation perspective, I'm using about as vanilla setup as possible -- "no" to pretty well all questions except "y" for Windows and "y" for Whitenoise; no cloud provider, using GitHub as CI tool).

When I open the project up in VSCode and setup a path to dmypy.exe correctly (as found in my virtual environment folder) I get the following error raised by VSCode:

Mypy settings changed: c:\Users\MYUSERNAME\Development\Navigator\nav
[3] Check workspace: c:\Users\MYUSERNAME\Development\Navigator\nav
[3] Received python path from Python extension: c:\Users\MYUSERNAME\Development\Navigator\.venv\Scripts\python.exe
[3] Running dmypy in folder c:\Users\MYUSERNAME\Development\Navigator\nav
'c:\Users\MYUSERNAME\Development\Navigator\nav\..\.venv\scripts\dmypy.exe' --status-file 'c:\Users\MYUSERNAME\AppData\Roaming\Code\User\workspaceStorage\0e535676e284b08a0f096efc595261d2\matangover.mypy\dmypy-25dcc9f6aa1070ea6d08209fdd5961c72b27b416.json' run --log-file 'c:\Users\MYUSERNAME\AppData\Roaming\Code\User\workspaceStorage\0e535676e284b08a0f096efc595261d2\matangover.mypy\dmypy-25dcc9f6aa1070ea6d08209fdd5961c72b27b416.log' -- . --show-column-numbers --no-error-summary --no-pretty --no-color-output --python-executable 'c:\Users\MYUSERNAME\Development\Navigator\.venv\Scripts\python.exe'
[3] stdout:
Daemon started
Restarting: configuration changed
Daemon stopped
Daemon started

[3] stderr:
Response: {'restart': 'configuration changed', 'platform': 'win32', 'python_version': '3_9', 'roundtrip_time': 0.5840277671813965}

[3] Error running mypy in c:\Users\MYUSERNAME\Development\Navigator\nav: mypy failed with error: "Response: {'restart': 'configuration changed', 'platform': 'win32', 'python_version': '3_9', 'roundtrip_time': 0.5840277671813965}

Here is my .vscode/settings.json file:

{
  "python.linting.mypyEnabled": true,
  "python.linting.enabled": true,
  "mypy.dmypyExecutable": "${workspaceFolder}\\..\\.venv\\scripts\\dmypy.exe"
}

I'm not quite sure how to further debug this issue ("configuration changed" isn't turning up relevant google results). What I know is that this extension works for other VSCode projects that I've manually added mypy to.

I'm not sure who exactly I should be raising my issue to -- this VSCode extension, mypy, or the Django Cookiecutter folks, so thought stackoverflow might bring the talents together. Thank you for any help or direction!

wolfpigeon
  • 143
  • 1
  • 7

1 Answers1

6

This is a known mypy issue.

The solution (for now) is to add an undocumented configuration instruction in setup.cfg:

ignore_missing_imports_per_module = True

I.e.,

…
[mypy]
python_version = 3.9
check_untyped_defs = True
ignore_missing_imports = True
ignore_missing_imports_per_module = True
warn_unused_ignores = True
…
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
wolfpigeon
  • 143
  • 1
  • 7