WIP: django_stubs_ext: monkeypatch reveal_{type,locals} into builtins (#591)

* WIP: django_stubs_ext: monkeypatch `reveal_{type,locals}` into builtins

Fixes https://github.com/typeddjango/django-stubs/issues/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>
This commit is contained in:
Daniel Hahler
2021-04-14 11:33:45 +02:00
committed by GitHub
parent 3c6f438cc9
commit ee58b18f15
2 changed files with 20 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import builtins
from contextlib import suppress
from typing import Optional
@@ -28,6 +29,9 @@ def make_generic_classes(
with suppress(AttributeError):
delattr(el.cls, "__class_getitem__")
del builtins.reveal_type
del builtins.reveal_locals
def factory(django_version: Optional[_VersionSpec] = None) -> None:
if django_version is not None:
monkeypatch.setattr(patch, "VERSION", django_version)
@@ -65,3 +69,12 @@ def test_patched_version_specific(
for el in _need_generic:
if el.version is not None and django_version <= el.version:
assert el.cls[int] is el.cls
def test_patched_mypy_builtins(make_generic_classes: _MakeGenericClasses) -> None:
make_generic_classes()
assert builtins.reveal_type
assert builtins.reveal_locals
reveal_type(reveal_locals) # noqa: F821