Consistently require Resource, not IResource.

This commit is contained in:
Patrick Cloke 2021-11-09 14:54:13 -05:00
parent 215e5b503e
commit cdaac71b0b
4 changed files with 10 additions and 10 deletions

View file

@ -17,7 +17,7 @@ import sys
from typing import Dict, Optional
from twisted.internet import address
from twisted.web.resource import IResource
from twisted.web.resource import Resource
from twisted.web.server import Request
import synapse
@ -270,7 +270,7 @@ class GenericWorkerServer(HomeServer):
site_tag = port
# We always include a health resource.
resources: Dict[str, IResource] = {"/health": HealthResource()}
resources: Dict[str, Resource] = {"/health": HealthResource()}
for res in listener_config.http_options.resources:
for name in res.names:

View file

@ -31,7 +31,7 @@ import attr
import jinja2
from twisted.internet import defer
from twisted.web.resource import IResource
from twisted.web.resource import Resource
from synapse.api.errors import SynapseError
from synapse.events import EventBase
@ -196,7 +196,7 @@ class ModuleApi:
"""
return self._password_auth_provider.register_password_auth_provider_callbacks
def register_web_resource(self, path: str, resource: IResource):
def register_web_resource(self, path: str, resource: Resource):
"""Registers a web resource to be served at the given path.
This function should be called during initialisation of the module.

View file

@ -35,7 +35,7 @@ from typing import (
import twisted.internet.tcp
from twisted.web.iweb import IPolicyForHTTPS
from twisted.web.resource import IResource
from twisted.web.resource import Resource
from synapse.api.auth import Auth
from synapse.api.filtering import Filtering
@ -257,10 +257,10 @@ class HomeServer(metaclass=abc.ABCMeta):
self.datastores: Optional[Databases] = None
self._module_web_resources: Dict[str, IResource] = {}
self._module_web_resources: Dict[str, Resource] = {}
self._module_web_resources_consumed = False
def register_module_web_resource(self, path: str, resource: IResource):
def register_module_web_resource(self, path: str, resource: Resource):
"""Allows a module to register a web resource to be served at the given path.
If multiple modules register a resource for the same path, the module that

View file

@ -92,9 +92,9 @@ def _resource_id(resource: Resource, path_seg: bytes) -> str:
the mapping should looks like _resource_id(A,C) = B.
Args:
resource (Resource): The *parent* Resourceb
path_seg (str): The name of the child Resource to be attached.
resource: The *parent* Resourceb
path_seg: The name of the child Resource to be attached.
Returns:
str: A unique string which can be a key to the child Resource.
A unique string which can be a key to the child Resource.
"""
return "%s-%r" % (resource, path_seg)