summary refs log tree commit diff
path: root/synapse/rest/client/_base.py
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2021-09-03 09:22:22 -0400
committerGitHub <noreply@github.com>2021-09-03 09:22:22 -0400
commitecbfa4fe4fa7625dec14ef8f9bd06cc4ad141de0 (patch)
tree732bb7811ccffe2c68fb59fbb8351486ff786d77 /synapse/rest/client/_base.py
parentFix bug with reusing 'txn' when persisting event. (#10743) (diff)
downloadsynapse-ecbfa4fe4fa7625dec14ef8f9bd06cc4ad141de0.tar.xz
Additional type hints for client REST servlets (part 5) (#10736)
Additionally this enforce type hints on all function signatures inside
of the synapse.rest.client package.
Diffstat (limited to 'synapse/rest/client/_base.py')
-rw-r--r--synapse/rest/client/_base.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/synapse/rest/client/_base.py b/synapse/rest/client/_base.py

index 0443f4571c..a0971ce994 100644 --- a/synapse/rest/client/_base.py +++ b/synapse/rest/client/_base.py
@@ -16,7 +16,7 @@ """ import logging import re -from typing import Iterable, Pattern +from typing import Any, Awaitable, Callable, Iterable, Pattern, Tuple, TypeVar, cast from synapse.api.errors import InteractiveAuthIncompleteError from synapse.api.urls import CLIENT_API_PREFIX @@ -76,7 +76,10 @@ def set_timeline_upper_limit(filter_json: JsonDict, filter_timeline_limit: int) ) -def interactive_auth_handler(orig): +C = TypeVar("C", bound=Callable[..., Awaitable[Tuple[int, JsonDict]]]) + + +def interactive_auth_handler(orig: C) -> C: """Wraps an on_POST method to handle InteractiveAuthIncompleteErrors Takes a on_POST method which returns an Awaitable (errcode, body) response @@ -91,10 +94,10 @@ def interactive_auth_handler(orig): await self.auth_handler.check_auth """ - async def wrapped(*args, **kwargs): + async def wrapped(*args: Any, **kwargs: Any) -> Tuple[int, JsonDict]: try: return await orig(*args, **kwargs) except InteractiveAuthIncompleteError as e: return 401, e.result - return wrapped + return cast(C, wrapped)