mirror of https://github.com/zulip/zulip.git
settings: Hide django_stubs_ext from mypy.
Fixes an import cycle that breaks mypy inference with django-stubs: zproject.settings → django_stubs_ext → django_stubs_ext.patch → django.contrib.admin.options → django.contrib.contenttypes.models → confirmation.models → django.conf → zproject.settings. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
72aeaf8d52
commit
73116f78a5
|
@ -15,13 +15,21 @@
|
||||||
# See https://zulip.readthedocs.io/en/latest/subsystems/settings.html for more information
|
# See https://zulip.readthedocs.io/en/latest/subsystems/settings.html for more information
|
||||||
#
|
#
|
||||||
########################################################################
|
########################################################################
|
||||||
import django_stubs_ext
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
# Monkey-patch certain types that are declared as generic types
|
# Monkey-patch certain types that are declared as generic types
|
||||||
# generic in django-stubs, but not (yet) as generic types in Django
|
# generic in django-stubs, but not (yet) as generic types in Django
|
||||||
# itself. This is necessary to ensure type references like
|
# itself. This is necessary to ensure type references like
|
||||||
# django.db.models.Lookup[int] work correctly at runtime.
|
# django.db.models.Lookup[int] work correctly at runtime.
|
||||||
django_stubs_ext.monkeypatch()
|
#
|
||||||
|
# Hide this from mypy to avoid creating stupid cycles like
|
||||||
|
# zproject.settings → django_stubs_ext → django_stubs_ext.patch →
|
||||||
|
# django.contrib.admin.options → django.contrib.contenttypes.models →
|
||||||
|
# confirmation.models → django.conf → zproject.settings.
|
||||||
|
if not TYPE_CHECKING:
|
||||||
|
import django_stubs_ext
|
||||||
|
|
||||||
|
django_stubs_ext.monkeypatch()
|
||||||
|
|
||||||
from .configured_settings import * # noqa: F403 isort: skip
|
from .configured_settings import * # noqa: F403 isort: skip
|
||||||
from .computed_settings import * # noqa: F403 isort: skip
|
from .computed_settings import * # noqa: F403 isort: skip
|
||||||
|
|
Loading…
Reference in New Issue