mirror of https://github.com/zulip/zulip.git
mypy: Specify generic type parameters in cachify decorator.
Use of the decorator in event_queue.py suggests concrete return type, for application of copy() function.
This commit is contained in:
parent
94554c65da
commit
790cd5e7c8
|
@ -75,11 +75,11 @@ def asynchronous(method):
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
def cachify(method):
|
def cachify(method):
|
||||||
# type: (Callable) -> Callable
|
# type: (Callable[..., ReturnT]) -> Callable[..., ReturnT]
|
||||||
dct = {} # type: Dict[Tuple, Any]
|
dct = {} # type: Dict[Tuple[Any, ...], ReturnT]
|
||||||
|
|
||||||
def cache_wrapper(*args):
|
def cache_wrapper(*args):
|
||||||
# type: (*Any) -> Any
|
# type: (*Any) -> ReturnT
|
||||||
tup = tuple(args)
|
tup = tuple(args)
|
||||||
if tup in dct:
|
if tup in dct:
|
||||||
return dct[tup]
|
return dct[tup]
|
||||||
|
|
|
@ -805,7 +805,7 @@ def process_message_event(event_template, users):
|
||||||
|
|
||||||
@cachify
|
@cachify
|
||||||
def get_client_payload(apply_markdown, client_gravatar):
|
def get_client_payload(apply_markdown, client_gravatar):
|
||||||
# type: (bool, bool) -> Mapping[str, Any]
|
# type: (bool, bool) -> Dict[str, Any]
|
||||||
dct = copy.deepcopy(wide_dict)
|
dct = copy.deepcopy(wide_dict)
|
||||||
MessageDict.finalize_payload(dct, apply_markdown, client_gravatar)
|
MessageDict.finalize_payload(dct, apply_markdown, client_gravatar)
|
||||||
return dct
|
return dct
|
||||||
|
|
Loading…
Reference in New Issue