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
def cachify(method):
# type: (Callable) -> Callable
dct = {} # type: Dict[Tuple, Any]
# type: (Callable[..., ReturnT]) -> Callable[..., ReturnT]
dct = {} # type: Dict[Tuple[Any, ...], ReturnT]
def cache_wrapper(*args):
# type: (*Any) -> Any
# type: (*Any) -> ReturnT
tup = tuple(args)
if tup in dct:
return dct[tup]

View File

@ -805,7 +805,7 @@ def process_message_event(event_template, users):
@cachify
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)
MessageDict.finalize_payload(dct, apply_markdown, client_gravatar)
return dct