1
0

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

@@ -18,7 +18,7 @@
# [This file includes modifications made by New Vector Limited]
#
#
from typing import List, Optional, Tuple
from typing import Optional
from twisted.internet.testing import MemoryReactor
@@ -99,7 +99,7 @@ class EndToEndKeyWorkerStoreTestCase(HomeserverTestCase):
def check_timestamp_column(
txn: LoggingTransaction,
) -> List[Tuple[JsonDict, Optional[int]]]:
) -> list[tuple[JsonDict, Optional[int]]]:
"""Fetch all rows for Alice's keys."""
txn.execute(
"""

View File

@@ -20,7 +20,7 @@
#
import json
from contextlib import contextmanager
from typing import Generator, List, Set, Tuple
from typing import Generator
from unittest import mock
from twisted.enterprise.adbapi import ConnectionPool
@@ -60,7 +60,7 @@ class HaveSeenEventsTestCase(unittest.HomeserverTestCase):
self.token = self.login(self.user, "pass")
self.room_id = self.helper.create_room_as(self.user, tok=self.token)
self.event_ids: List[str] = []
self.event_ids: list[str] = []
for i in range(3):
event = self.get_success(
inject_event(
@@ -316,7 +316,7 @@ class GetEventsTestCase(unittest.HomeserverTestCase):
room_id = self.helper.create_room_as(user_id, tok=user_tok)
event_ids: Set[str] = set()
event_ids: set[str] = set()
for i in range(num_events):
event = self.get_success(
inject_event(
@@ -371,7 +371,7 @@ class DatabaseOutageTestCase(unittest.HomeserverTestCase):
)
)
self.event_ids: List[str] = []
self.event_ids: list[str] = []
for idx in range(1, 21): # Stream ordering starts at 1.
event_json = {
"type": f"test {idx}",
@@ -504,7 +504,7 @@ class GetEventCancellationTestCase(unittest.HomeserverTestCase):
def blocking_get_event_calls(
self,
) -> Generator[
Tuple["Deferred[None]", "Deferred[None]", "Deferred[None]"], None, None
tuple["Deferred[None]", "Deferred[None]", "Deferred[None]"], None, None
]:
"""Starts two concurrent `get_event` calls for the same event.

View File

@@ -19,7 +19,7 @@
#
#
from typing import Any, Dict, Optional, Sequence, Tuple
from typing import Any, Optional, Sequence
from twisted.internet.testing import MemoryReactor
@@ -51,8 +51,8 @@ class ReceiptsBackgroundUpdateStoreTestCase(HomeserverTestCase):
update_name: str,
index_name: str,
table: str,
receipts: Dict[Tuple[str, str, str], Sequence[Dict[str, Any]]],
expected_unique_receipts: Dict[Tuple[str, str, str], Optional[Dict[str, Any]]],
receipts: dict[tuple[str, str, str], Sequence[dict[str, Any]]],
expected_unique_receipts: dict[tuple[str, str, str], Optional[dict[str, Any]]],
) -> None:
"""Test that the background update to uniqueify non-thread receipts in
the given receipts table works properly.