mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-19 08:54:05 -04:00
Additional type hints for the proxy agent and SRV resolver modules. (#10608)
This commit is contained in:
parent
78a70a2e0b
commit
0c3565da4c
5 changed files with 41 additions and 25 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue