Additional type hints for the proxy agent and SRV resolver modules. (#10608)

This commit is contained in:
Dirk Klimpel 2021-08-18 19:53:20 +02:00 committed by GitHub
parent 78a70a2e0b
commit 0c3565da4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 25 deletions

View file

@ -12,8 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING
from twisted.web.server import Request
from synapse.http.server import DirectServeJsonResource
if TYPE_CHECKING:
from synapse.server import HomeServer
class AdditionalResource(DirectServeJsonResource):
"""Resource wrapper for additional_resources
@ -25,7 +32,7 @@ class AdditionalResource(DirectServeJsonResource):
and exception handling.
"""
def __init__(self, hs, handler):
def __init__(self, hs: "HomeServer", handler):
"""Initialise AdditionalResource
The ``handler`` should return a deferred which completes when it has
@ -33,14 +40,14 @@ class AdditionalResource(DirectServeJsonResource):
``request.write()``, and call ``request.finish()``.
Args:
hs (synapse.server.HomeServer): homeserver
hs: homeserver
handler ((twisted.web.server.Request) -> twisted.internet.defer.Deferred):
function to be called to handle the request.
"""
super().__init__()
self._handler = handler
def _async_render(self, request):
def _async_render(self, request: Request):
# Cheekily pass the result straight through, so we don't need to worry
# if its an awaitable or not.
return self._handler(request)