From 552b58afb737d362d68eeb782bd04d0e33db26f6 Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Thu, 23 Jun 2022 14:23:46 -0400 Subject: [PATCH] display_recipient: Tighten function signatures with ValuesQuerySet. Signed-off-by: Zixuan James Li --- zerver/lib/display_recipient.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/zerver/lib/display_recipient.py b/zerver/lib/display_recipient.py index f6ed0c1d45..8b296d562c 100644 --- a/zerver/lib/display_recipient.py +++ b/zerver/lib/display_recipient.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional, Set, Tuple, TypedDict +from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, TypedDict from zerver.lib.cache import ( bulk_cached_fetch, @@ -10,6 +10,9 @@ from zerver.lib.cache import ( from zerver.lib.types import DisplayRecipientT, UserDisplayRecipient from zerver.models import Recipient, Stream, UserProfile, bulk_get_huddle_user_ids +if TYPE_CHECKING: + from django.db.models.query import _QuerySet as ValuesQuerySet + display_recipient_fields = [ "id", "email", @@ -96,7 +99,9 @@ def bulk_fetch_display_recipients( } personal_and_huddle_recipients = recipient_tuples - stream_recipients - def stream_query_function(recipient_ids: List[int]) -> List[TinyStreamResult]: + def stream_query_function( + recipient_ids: List[int], + ) -> "ValuesQuerySet[Stream, TinyStreamResult]": stream_ids = [ recipient_id_to_type_pair_dict[recipient_id][1] for recipient_id in recipient_ids ]