Error importing plugin 'mypy_django_plugin.main'
See original GitHub issue(As per #160, I’m forking a dedicated issue for this.)
I’m using mypy 0.720 with django-stubs 1.1.0 (from PyPI today):
$ mypy --version
mypy 0.720
$ pip show django-stubs
Name: django-stubs
Version: 1.1.0
With plugins = mypy_django_plugin.main in mypy.ini, mypy fails as follows:
mypy -p foo.bar
../mypy.ini:12: error: Error importing plugin 'mypy_django_plugin.main'
even though mypy_django_plugin loads just fine.
I’ve tried dropping .main from the mypy.ini and that gives:
../mypy.ini:12: error: Plugin 'mypy_django_plugin' does not define entry point function "plugin"
I’ve also tried replacing .main with :main (which seems to be the current recommended way to specify entry points in mypy.ini) and that gives:
../mypy.ini:12: error: Plugin 'mypy_django_plugin' does not define entry point function "main"
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:13 (5 by maintainers)
Top Results From Across the Web
mypy-django/Lobby - Gitter
Hi guys, setting up mypy-django, i get this error. Error importing plugin 'mypy_django_plugin.main'. done just pip install and added mypy_django_plugin.main ...
Read more >MyPy, VSCode, Django, ModuleNotFound - Stack Overflow
BTW, it works if I run MyPy in terminal. Error: ModuleNotFoundError: No module named 'my_project.settings'. mypy.ini: [mypy] plugins = ...
Read more >django-stubs - PyPI
[mypy] plugins = mypy_django_plugin.main [mypy.plugins.django-stubs] ... You can also run mypy with --tb option to get extra information about the error.
Read more >Type Check Your Django Application - Technical Ramblings
The talk was about adding Python gradual typing to Django using ... false plugins = mypy_django_plugin.main, [mypy.plugins.django-stubs] ...
Read more >Mypy Plugin: PEP-484 Stubs for Django - Morioh
[mypy] plugins = mypy_django_plugin.main [mypy.plugins.django-stubs] ... from typing import TypedDict from django_stubs_ext import WithAnnotations from ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
was facing the same issue, but placing
[mypy.plugins.django-stubs]before setting plugins in setup.cfg fixed it for me.I’m able to repro this in Django v2 as well.
This happens at module import time, before the
DjangoContextgets initialized (and sets up django). A hacky fix is to move theArrayFieldimport block inside theDjangoContext.__init__func after theinitialize_djangocall. This works because the class is only referenced inside an instantiated version of the class. Although I admit, this is not a viable long-term solution.An example of this is here: https://github.com/typeddjango/django-stubs/compare/master...sklarsa:issue-166