-
-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'reveal_type' is not defined when using mypy_django_plugin #590
Comments
Yes, this happens because we first run I suggest to use this hack: from typing import TYPE_CHECKING
if not TYPE_CHECKING:
reveal_type = print |
Thanks for the explanation and the workaround. But I'd also like to clarify if there isn't something that could be done to fix/improve this in general, i.e. in case plugins are not really meant to import modules / run code already (what (the "custom") django-stubs/mypy_django_plugin/django/context.py Lines 69 to 72 in f003968
As for the hack the following appears to be more feasible (as an editor snippet/shortcut then): from typing import TYPE_CHECKING
if TYPE_CHECKING:
reveal_type(expr) And django-stubs itself could maybe add something like the following (while running " from typing import TYPE_CHECKING
if not TYPE_CHECKING:
import builtins
builtins.reveal_type = lambda _: None
builtins.reveal_locals = lambda: None |
Hm, probably we can add Do you want to work on this? |
Sounds good!
=> #591 |
…ns (#591) * WIP: django_stubs_ext: monkeypatch `reveal_{type,locals}` into builtins Fixes #590 * fixup! WIP: django_stubs_ext: monkeypatch `reveal_{type,locals}` into builtins * fixup! fixup! WIP: django_stubs_ext: monkeypatch `reveal_{type,locals}` into builtins * Update patch.py Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@sobolevn I think it a) should not require to use the |
Yes, looks like it is a good idea indeed. But, |
facing the same issue right now |
You have |
sure about this?
|
Yes, I am sure :)
With import:
|
Mypy doesn't require reveal_type import, but Python itself does require it to be imported. |
Using
reveal_type
in a module fails when usingplugins = project.mypy_django_plugin
(via[mypy]
section insetup.cfg
):System information
python
version: Python 3.9.2django
version: Django 3.1.8mypy
version: mypy 0.812django-stubs
version: f003968 (current master)The text was updated successfully, but these errors were encountered: