diff --git a/zproject/settings.py b/zproject/settings.py index 42d9d79797..2d413b785e 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -15,13 +15,21 @@ # 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 # generic in django-stubs, but not (yet) as generic types in Django # itself. This is necessary to ensure type references like # 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 .computed_settings import * # noqa: F403 isort: skip