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:
neiljp (Neil Pilgrim) 2017-11-07 20:43:05 -08:00 committed by Tim Abbott
parent 94554c65da
commit 790cd5e7c8
2 changed files with 4 additions and 4 deletions

View File

@ -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]

View File

@ -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