mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-13 07:21:56 +08:00
[WIP/RFC] Revisit patching of mypy builtins (reveal_{type,locals}) (#615)
* Revisit patching of mypy builtins (reveal_{type,locals})
Fixes https://github.com/typeddjango/django-stubs/issues/609
Reverts ee58b18f15
* Create test_patching.yml
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import builtins
|
||||
import os
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
@@ -60,6 +61,13 @@ def initialize_django(settings_module: str) -> Tuple["Apps", "LazySettings"]:
|
||||
models.QuerySet.__class_getitem__ = classmethod(noop_class_getitem) # type: ignore
|
||||
models.Manager.__class_getitem__ = classmethod(noop_class_getitem) # type: ignore
|
||||
|
||||
# Define mypy builtins, to not cause NameError during setting up Django.
|
||||
# TODO: temporary/unpatch
|
||||
assert not hasattr(builtins, "reveal_type")
|
||||
builtins.reveal_type = lambda _: None
|
||||
assert not hasattr(builtins, "reveal_locals")
|
||||
builtins.reveal_locals = lambda: None
|
||||
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
Reference in New Issue
Block a user