mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 19:04:51 -04:00
Add missing type hints to synapse.http. (#11571)
This commit is contained in:
parent
ff6fd52160
commit
33abbc3278
8 changed files with 76 additions and 51 deletions
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Optional, Tuple
|
||||
|
||||
from twisted.web.server import Request
|
||||
|
||||
|
@ -32,7 +32,11 @@ class AdditionalResource(DirectServeJsonResource):
|
|||
and exception handling.
|
||||
"""
|
||||
|
||||
def __init__(self, hs: "HomeServer", handler):
|
||||
def __init__(
|
||||
self,
|
||||
hs: "HomeServer",
|
||||
handler: Callable[[Request], Awaitable[Optional[Tuple[int, Any]]]],
|
||||
):
|
||||
"""Initialise AdditionalResource
|
||||
|
||||
The ``handler`` should return a deferred which completes when it has
|
||||
|
@ -47,7 +51,7 @@ class AdditionalResource(DirectServeJsonResource):
|
|||
super().__init__()
|
||||
self._handler = handler
|
||||
|
||||
def _async_render(self, request: Request):
|
||||
async def _async_render(self, request: Request) -> Optional[Tuple[int, Any]]:
|
||||
# Cheekily pass the result straight through, so we don't need to worry
|
||||
# if its an awaitable or not.
|
||||
return self._handler(request)
|
||||
return await self._handler(request)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue