typing: Import ValuesQuerySet alias from django_stubs_ext.

This saves us from using a conditional import.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li
2022-09-19 15:48:53 -04:00
committed by Tim Abbott
parent a4eaa770f0
commit 7fd8d77ce0
8 changed files with 24 additions and 51 deletions

View File

@@ -1,12 +1,13 @@
# See https://zulip.readthedocs.io/en/latest/subsystems/caching.html for docs
import datetime
import logging
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, Tuple
from typing import Any, Callable, Dict, Iterable, Tuple
from django.conf import settings
from django.contrib.sessions.models import Session
from django.db.models.query import QuerySet
from django.utils.timezone import now as timezone_now
from django_stubs_ext import ValuesQuerySet
# This file needs to be different from cache.py because cache.py
# cannot import anything from zerver.models or we'd have an import
@@ -32,9 +33,6 @@ from zerver.models import (
huddle_hash_cache_key,
)
if TYPE_CHECKING:
from django.db.models.query import _QuerySet as ValuesQuerySet
def user_cache_items(
items_for_remote_cache: Dict[str, Tuple[UserProfile]], user_profile: UserProfile
@@ -73,7 +71,7 @@ def session_cache_items(
items_for_remote_cache[store.cache_key] = store.decode(session.session_data)
def get_active_realm_ids() -> "ValuesQuerySet[RealmCount, int]":
def get_active_realm_ids() -> ValuesQuerySet[RealmCount, int]:
"""For installations like Zulip Cloud hosting a lot of realms, it only makes
sense to do cache-filling work for realms that have any currently
active users/clients. Otherwise, we end up with every single-user