mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
import_util: Strengthen get_users type using a Protocol.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
3117969f03
commit
a1ba3ca066
@@ -9,6 +9,7 @@ from typing import AbstractSet, Any, Callable, Dict, Iterable, List, Optional, S
|
|||||||
import orjson
|
import orjson
|
||||||
import requests
|
import requests
|
||||||
from django.forms.models import model_to_dict
|
from django.forms.models import model_to_dict
|
||||||
|
from typing_extensions import Protocol
|
||||||
|
|
||||||
from zerver.data_import.sequencer import NEXT_ID
|
from zerver.data_import.sequencer import NEXT_ID
|
||||||
from zerver.lib.actions import STREAM_ASSIGNMENT_COLORS as stream_colors
|
from zerver.lib.actions import STREAM_ASSIGNMENT_COLORS as stream_colors
|
||||||
@@ -223,8 +224,13 @@ def build_public_stream_subscriptions(
|
|||||||
return subscriptions
|
return subscriptions
|
||||||
|
|
||||||
|
|
||||||
|
class GetUsers(Protocol):
|
||||||
|
def __call__(self, stream_id: int = ..., huddle_id: int = ...) -> Set[int]:
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
def build_stream_subscriptions(
|
def build_stream_subscriptions(
|
||||||
get_users: Callable[..., Set[int]],
|
get_users: GetUsers,
|
||||||
zerver_recipient: List[ZerverFieldsT],
|
zerver_recipient: List[ZerverFieldsT],
|
||||||
zerver_stream: List[ZerverFieldsT],
|
zerver_stream: List[ZerverFieldsT],
|
||||||
) -> List[ZerverFieldsT]:
|
) -> List[ZerverFieldsT]:
|
||||||
@@ -253,7 +259,7 @@ def build_stream_subscriptions(
|
|||||||
|
|
||||||
|
|
||||||
def build_huddle_subscriptions(
|
def build_huddle_subscriptions(
|
||||||
get_users: Callable[..., Set[int]],
|
get_users: GetUsers,
|
||||||
zerver_recipient: List[ZerverFieldsT],
|
zerver_recipient: List[ZerverFieldsT],
|
||||||
zerver_huddle: List[ZerverFieldsT],
|
zerver_huddle: List[ZerverFieldsT],
|
||||||
) -> List[ZerverFieldsT]:
|
) -> List[ZerverFieldsT]:
|
||||||
|
|||||||
Reference in New Issue
Block a user