admin管理员组文章数量:1246701
I'm using VSCode with the mypy plugin in my Django project. My pyproject.toml configuration looks like this (following the Django Stubs README):
[tool.mypy]
mypy_path = "."
python_version = "3.13"
strict = true
plugins = ["mypy_django_plugin.main"]
[tool.django-stubs]
django_settings_module = "conf.settings"
When I run mypy in the terminal, everything works fine, and I get proper type checking.
However, in VSCode, I don't get any type hints at all. If I comment out the plugins line, mypy starts working in VSCode again.
What I've Tried:
- Running mypy manually in the terminal → Works as expected
- Commenting out plugins → VSCode starts showing hints again
- Checking that VSCode uses the correct mypy config (it's picking up pyproject.toml)
Any insights would be greatly appreciated!
EDIT: Using VSCode inside my Docker container via Remote Exploxer works. So I guess Django needs to be booted in my VSCode environment for the mypy plugins to work properly. It would be nice to have a workaround though.
EDIT2: I found this error message in the VSCode Output terminal:
django.core.exceptions.ImproperlyConfigured: 'django.db.backends.None' isn't an available database backend or couldn't be imported. Check the above exception. To use one of the built-in backends, use 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'postgresql', 'sqlite3'
本文标签: pythonVSCode Ignores Mypy Type Hints When Using Django PluginsStack Overflow
版权声明:本文标题:python - VSCode Ignores Mypy Type Hints When Using Django Plugins - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740150358a2232542.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论