extract_recipients: Support user IDs.

This is a part of our efforts surrounding #9474.
This commit is contained in:
Eeshan Garg
2018-08-21 21:51:34 -02:30
parent fbffbf8ef0
commit 8f1dba6aad
4 changed files with 79 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
from typing import TypeVar, Callable, Optional, List, Dict, Union, Tuple, Any
from typing import TypeVar, Callable, Optional, List, Dict, Union, Tuple, Any, Iterable
from django.http import HttpResponse
ViewFuncT = TypeVar('ViewFuncT', bound=Callable[..., HttpResponse])
@@ -6,6 +6,12 @@ ViewFuncT = TypeVar('ViewFuncT', bound=Callable[..., HttpResponse])
# See zerver/lib/validator.py for more details of Validators,
# including many examples
Validator = Callable[[str, object], Optional[str]]
# This type is specific for zerver.lib.actions.extract_recipients. After
# deciding to support IDs for some of our API, extract_recipients'
# implementation diverged from other converter functions in many ways.
# See zerver/lib/request.pyi to see how this is used.
ExtractRecipients = Callable[[Union[str, Iterable[str], Iterable[int]]], Union[List[str], List[int]]]
ExtendedValidator = Callable[[str, str, object], Optional[str]]
RealmUserValidator = Callable[[int, List[int], bool], Optional[str]]