mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	subscription_info: Tighten function signatures with generic QuerySet.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							0528935b82
						
					
				
				
					commit
					d7d6aa31bb
				
			@@ -1,7 +1,18 @@
 | 
			
		||||
import hashlib
 | 
			
		||||
from collections import defaultdict
 | 
			
		||||
from dataclasses import dataclass
 | 
			
		||||
from typing import Any, Collection, Dict, Iterable, List, Mapping, Optional, Set, Tuple
 | 
			
		||||
from typing import (
 | 
			
		||||
    TYPE_CHECKING,
 | 
			
		||||
    Any,
 | 
			
		||||
    Collection,
 | 
			
		||||
    Dict,
 | 
			
		||||
    Iterable,
 | 
			
		||||
    List,
 | 
			
		||||
    Mapping,
 | 
			
		||||
    Optional,
 | 
			
		||||
    Set,
 | 
			
		||||
    Tuple,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
import orjson
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
@@ -64,6 +75,9 @@ from zerver.models import (
 | 
			
		||||
)
 | 
			
		||||
from zerver.tornado.django_api import send_event
 | 
			
		||||
 | 
			
		||||
if TYPE_CHECKING:
 | 
			
		||||
    from django.db.models.query import _QuerySet as ValuesQuerySet
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@transaction.atomic(savepoint=False)
 | 
			
		||||
def do_deactivate_stream(
 | 
			
		||||
@@ -133,7 +147,9 @@ def do_deactivate_stream(
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_subscriber_ids(stream: Stream, requesting_user: Optional[UserProfile] = None) -> List[str]:
 | 
			
		||||
def get_subscriber_ids(
 | 
			
		||||
    stream: Stream, requesting_user: Optional[UserProfile] = None
 | 
			
		||||
) -> "ValuesQuerySet[Subscription, int]":
 | 
			
		||||
    subscriptions_query = get_subscribers_query(stream, requesting_user)
 | 
			
		||||
    return subscriptions_query.values_list("user_profile_id", flat=True)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -370,8 +370,9 @@ def bulk_get_subscriber_user_ids(
 | 
			
		||||
    return result
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_subscribers_query(stream: Stream, requesting_user: Optional[UserProfile]) -> QuerySet:
 | 
			
		||||
    # TODO: Make a generic stub for QuerySet
 | 
			
		||||
def get_subscribers_query(
 | 
			
		||||
    stream: Stream, requesting_user: Optional[UserProfile]
 | 
			
		||||
) -> QuerySet[Subscription]:
 | 
			
		||||
    """Build a query to get the subscribers list for a stream, raising a JsonableError if:
 | 
			
		||||
 | 
			
		||||
    'realm' is optional in stream.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user