mirror of https://github.com/zulip/zulip.git
db: Split reset_queries into a new module zerver.lib.db_connections.
Fixes an import cycle that breaks mypy inference with django-stubs: zproject.settings → zproject.computed_settings → zerver.lib.db → django.db → django.db.backends.base.base → django.db.backends.base.features → django.db.models.base → django.db.models.options → django.contrib.contenttypes.fields → django.contrib.contenttypes.models → confirmation.models → django.conf → zproject.settings Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
245357c868
commit
72aeaf8d52
|
@ -51,11 +51,3 @@ class TimeTrackingConnection(connection):
|
|||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
self.queries: List[Dict[str, str]] = []
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
def reset_queries() -> None:
|
||||
from django.db import connections
|
||||
|
||||
for conn in connections.all():
|
||||
if conn.connection is not None:
|
||||
conn.connection.queries = []
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
from django.db import connections
|
||||
|
||||
|
||||
def reset_queries() -> None:
|
||||
for conn in connections.all():
|
||||
if conn.connection is not None:
|
||||
conn.connection.queries = []
|
|
@ -25,7 +25,7 @@ from sentry_sdk import set_tag
|
|||
from typing_extensions import Annotated, Concatenate, ParamSpec, override
|
||||
|
||||
from zerver.lib.cache import get_remote_cache_requests, get_remote_cache_time
|
||||
from zerver.lib.db import reset_queries
|
||||
from zerver.lib.db_connections import reset_queries
|
||||
from zerver.lib.debug import maybe_tracemalloc_listen
|
||||
from zerver.lib.exceptions import ErrorCode, JsonableError, MissingAuthenticationError, WebhookError
|
||||
from zerver.lib.markdown import get_markdown_requests, get_markdown_time
|
||||
|
|
|
@ -16,7 +16,7 @@ from returns.curry import partial
|
|||
from typing_extensions import override
|
||||
|
||||
from zerver.lib.context_managers import lockfile
|
||||
from zerver.lib.db import reset_queries
|
||||
from zerver.lib.db_connections import reset_queries
|
||||
from zerver.lib.per_request_cache import flush_per_request_caches
|
||||
from zerver.lib.pysa import mark_sanitized
|
||||
from zerver.lib.queue import SimpleQueueClient
|
||||
|
|
|
@ -11,7 +11,7 @@ from django.db.utils import IntegrityError
|
|||
from django.utils.timezone import now as timezone_now
|
||||
from typing_extensions import override
|
||||
|
||||
from zerver.lib.db import reset_queries
|
||||
from zerver.lib.db_connections import reset_queries
|
||||
from zerver.lib.email_notifications import MissedMessageData, handle_missedmessage_emails
|
||||
from zerver.lib.per_request_cache import flush_per_request_caches
|
||||
from zerver.models import ScheduledMessageNotificationEmail
|
||||
|
|
Loading…
Reference in New Issue