diff --git a/synapse/http/servlet.py b/synapse/http/servlet.py index 597980256e7..9473fe2fb31 100644 --- a/synapse/http/servlet.py +++ b/synapse/http/servlet.py @@ -75,8 +75,7 @@ def parse_integer( default: Optional[int] = None, required: bool = False, negative: bool = False, -) -> int: - ... +) -> int: ... def parse_integer( @@ -131,8 +130,7 @@ def parse_integer_from_args( default: Optional[int] = None, required: bool = False, negative: bool = False, -) -> Optional[int]: - ... +) -> Optional[int]: ... def parse_integer_from_args( diff --git a/synapse/rest/admin/federation.py b/synapse/rest/admin/federation.py index d41ce9aa4c4..14ab4644cb9 100644 --- a/synapse/rest/admin/federation.py +++ b/synapse/rest/admin/federation.py @@ -23,7 +23,7 @@ from typing import TYPE_CHECKING, Tuple from synapse.api.constants import Direction -from synapse.api.errors import Codes, NotFoundError, SynapseError +from synapse.api.errors import NotFoundError, SynapseError from synapse.federation.transport.server import Authenticator from synapse.http.servlet import RestServlet, parse_enum, parse_integer, parse_string from synapse.http.site import SynapseRequest diff --git a/synapse/rest/admin/media.py b/synapse/rest/admin/media.py index dbfdaa3bfeb..a05b7252ec0 100644 --- a/synapse/rest/admin/media.py +++ b/synapse/rest/admin/media.py @@ -323,7 +323,6 @@ async def on_POST( errcode=Codes.INVALID_PARAM, ) - # This check is useless, we keep it for the legacy endpoint only. if server_name is not None and self.server_name != server_name: raise SynapseError(HTTPStatus.BAD_REQUEST, "Can only delete local media") @@ -425,7 +424,6 @@ async def on_DELETE( start = parse_integer(request, "from", default=0, negative=False) limit = parse_integer(request, "limit", default=100, negative=False) - # If neither `order_by` nor `dir` is set, set the default order # to newest media is on top for backward compatibility. if b"order_by" not in request.args and b"dir" not in request.args: diff --git a/synapse/rest/admin/statistics.py b/synapse/rest/admin/statistics.py index 167d486fb6a..dc27a41dd98 100644 --- a/synapse/rest/admin/statistics.py +++ b/synapse/rest/admin/statistics.py @@ -67,7 +67,7 @@ async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]: limit = parse_integer(request, "limit", default=100, negative=False) from_ts = parse_integer(request, "from_ts", default=0, negative=False) until_ts = parse_integer(request, "until_ts", negative=False) - + if until_ts is not None: if until_ts <= from_ts: raise SynapseError( diff --git a/tests/rest/admin/test_media.py b/tests/rest/admin/test_media.py index c8476039e9b..f3781655132 100644 --- a/tests/rest/admin/test_media.py +++ b/tests/rest/admin/test_media.py @@ -277,7 +277,8 @@ def test_missing_parameter(self) -> None: self.assertEqual(400, channel.code, msg=channel.json_body) self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"]) self.assertEqual( - "Missing required integer query parameter before_ts", channel.json_body["error"] + "Missing required integer query parameter before_ts", + channel.json_body["error"], ) def test_invalid_parameter(self) -> None: