Use type hinting generics in standard collections (#19046)

aka PEP 585, added in Python 3.9

 - https://peps.python.org/pep-0585/
 - https://docs.astral.sh/ruff/rules/non-pep585-annotation/
This commit is contained in:
Andrew Ferrazzutti
2025-10-22 17:48:19 -04:00
committed by GitHub
parent cba3a814c6
commit fc244bb592
539 changed files with 4599 additions and 5066 deletions

View File

@@ -20,7 +20,7 @@
import re
from http import HTTPStatus
from typing import Awaitable, Callable, Dict, NoReturn, Optional, Tuple
from typing import Awaitable, Callable, NoReturn, Optional
from twisted.internet.defer import Deferred
from twisted.web.resource import Resource
@@ -70,7 +70,7 @@ class JsonResourceTests(unittest.TestCase):
def _callback(
request: SynapseRequest, **kwargs: object
) -> Tuple[int, Dict[str, object]]:
) -> tuple[int, dict[str, object]]:
got_kwargs.update(kwargs)
return 200, kwargs
@@ -192,7 +192,7 @@ class JsonResourceTests(unittest.TestCase):
def _callback(
request: SynapseRequest, **kwargs: object
) -> Tuple[int, Dict[str, object]]:
) -> tuple[int, dict[str, object]]:
return 200, {"result": True}
res = JsonResource(self.homeserver)
@@ -405,11 +405,11 @@ class CancellableDirectServeJsonResource(DirectServeJsonResource):
self.clock = clock
@cancellable
async def _async_render_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
async def _async_render_GET(self, request: SynapseRequest) -> tuple[int, JsonDict]:
await self.clock.sleep(1.0)
return HTTPStatus.OK, {"result": True}
async def _async_render_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
async def _async_render_POST(self, request: SynapseRequest) -> tuple[int, JsonDict]:
await self.clock.sleep(1.0)
return HTTPStatus.OK, {"result": True}
@@ -422,11 +422,11 @@ class CancellableDirectServeHtmlResource(DirectServeHtmlResource):
self.clock = clock
@cancellable
async def _async_render_GET(self, request: SynapseRequest) -> Tuple[int, bytes]:
async def _async_render_GET(self, request: SynapseRequest) -> tuple[int, bytes]:
await self.clock.sleep(1.0)
return HTTPStatus.OK, b"ok"
async def _async_render_POST(self, request: SynapseRequest) -> Tuple[int, bytes]:
async def _async_render_POST(self, request: SynapseRequest) -> tuple[int, bytes]:
await self.clock.sleep(1.0)
return HTTPStatus.OK, b"ok"