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:
committed by
GitHub
parent
cba3a814c6
commit
fc244bb592
@@ -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(
|
||||
"""
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#
|
||||
|
||||
import secrets
|
||||
from typing import Generator, List, Tuple, cast
|
||||
from typing import Generator, cast
|
||||
|
||||
from twisted.internet.testing import MemoryReactor
|
||||
|
||||
@@ -52,9 +52,9 @@ class UpdateUpsertManyTests(unittest.HomeserverTestCase):
|
||||
)
|
||||
)
|
||||
|
||||
def _dump_table_to_tuple(self) -> Generator[Tuple[int, str, str], None, None]:
|
||||
def _dump_table_to_tuple(self) -> Generator[tuple[int, str, str], None, None]:
|
||||
yield from cast(
|
||||
List[Tuple[int, str, str]],
|
||||
list[tuple[int, str, str]],
|
||||
self.get_success(
|
||||
self.storage.db_pool.simple_select_list(
|
||||
self.table_name, None, ["id, username, value"]
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import Iterable, Optional, Set
|
||||
from typing import Iterable, Optional
|
||||
|
||||
from twisted.internet.testing import MemoryReactor
|
||||
|
||||
@@ -52,7 +52,7 @@ class IgnoredUsersTestCase(unittest.HomeserverTestCase):
|
||||
)
|
||||
|
||||
def assert_ignorers(
|
||||
self, ignored_user_id: str, expected_ignorer_user_ids: Set[str]
|
||||
self, ignored_user_id: str, expected_ignorer_user_ids: set[str]
|
||||
) -> None:
|
||||
self.assertEqual(
|
||||
self.get_success(self.store.ignored_by(ignored_user_id)),
|
||||
@@ -60,7 +60,7 @@ class IgnoredUsersTestCase(unittest.HomeserverTestCase):
|
||||
)
|
||||
|
||||
def assert_ignored(
|
||||
self, ignorer_user_id: str, expected_ignored_user_ids: Set[str]
|
||||
self, ignorer_user_id: str, expected_ignored_user_ids: set[str]
|
||||
) -> None:
|
||||
self.assertEqual(
|
||||
self.get_success(self.store.ignored_users(ignorer_user_id)),
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
from typing import List, cast
|
||||
from typing import cast
|
||||
from unittest.mock import AsyncMock, Mock
|
||||
|
||||
import yaml
|
||||
@@ -48,7 +48,7 @@ class ApplicationServiceStoreTestCase(unittest.HomeserverTestCase):
|
||||
def setUp(self) -> None:
|
||||
super().setUp()
|
||||
|
||||
self.as_yaml_files: List[str] = []
|
||||
self.as_yaml_files: list[str] = []
|
||||
|
||||
self.hs.config.appservice.app_service_config_files = self.as_yaml_files
|
||||
self.hs.config.caches.event_cache_size = 1
|
||||
@@ -123,7 +123,7 @@ class ApplicationServiceStoreTestCase(unittest.HomeserverTestCase):
|
||||
class ApplicationServiceTransactionStoreTestCase(unittest.HomeserverTestCase):
|
||||
def setUp(self) -> None:
|
||||
super().setUp()
|
||||
self.as_yaml_files: List[str] = []
|
||||
self.as_yaml_files: list[str] = []
|
||||
|
||||
self.hs.config.appservice.app_service_config_files = self.as_yaml_files
|
||||
self.hs.config.caches.event_cache_size = 1
|
||||
@@ -180,7 +180,7 @@ class ApplicationServiceTransactionStoreTestCase(unittest.HomeserverTestCase):
|
||||
)
|
||||
|
||||
def _insert_txn(
|
||||
self, as_id: str, txn_id: int, events: List[Mock]
|
||||
self, as_id: str, txn_id: int, events: list[Mock]
|
||||
) -> "defer.Deferred[None]":
|
||||
return self.db_pool.runOperation(
|
||||
self.engine.convert_param_style(
|
||||
@@ -277,7 +277,7 @@ class ApplicationServiceTransactionStoreTestCase(unittest.HomeserverTestCase):
|
||||
self,
|
||||
) -> None:
|
||||
service = Mock(id=self.as_list[0]["id"])
|
||||
events = cast(List[EventBase], [Mock(event_id="e1"), Mock(event_id="e2")])
|
||||
events = cast(list[EventBase], [Mock(event_id="e1"), Mock(event_id="e2")])
|
||||
txn = self.get_success(
|
||||
defer.ensureDeferred(
|
||||
self.store.create_appservice_txn(
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
#
|
||||
import logging
|
||||
from typing import List, Tuple, cast
|
||||
from typing import cast
|
||||
from unittest.mock import AsyncMock, Mock
|
||||
|
||||
import yaml
|
||||
@@ -535,7 +535,7 @@ class BackgroundUpdateValidateConstraintTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# Check the correct values are in the new table.
|
||||
rows = cast(
|
||||
List[Tuple[int, int]],
|
||||
list[tuple[int, int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="test_constraint",
|
||||
@@ -652,7 +652,7 @@ class BackgroundUpdateValidateConstraintTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# Check the correct values are in the new table.
|
||||
rows = cast(
|
||||
List[Tuple[int, int]],
|
||||
list[tuple[int, int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="test_constraint",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import Any, Dict, List, Optional, Tuple, cast
|
||||
from typing import Any, Optional, cast
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from parameterized import parameterized
|
||||
@@ -104,7 +104,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
self.pump(0)
|
||||
|
||||
result = cast(
|
||||
List[Tuple[str, str, str, Optional[str], int]],
|
||||
list[tuple[str, str, str, Optional[str], int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -135,7 +135,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
self.pump(0)
|
||||
|
||||
result = cast(
|
||||
List[Tuple[str, str, str, Optional[str], int]],
|
||||
list[tuple[str, str, str, Optional[str], int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -184,7 +184,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
else:
|
||||
# Check that the new IP and user agent has not been stored yet
|
||||
db_result = cast(
|
||||
List[Tuple[str, Optional[str], Optional[str], str, Optional[int]]],
|
||||
list[tuple[str, Optional[str], Optional[str], str, Optional[int]]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="devices",
|
||||
@@ -266,7 +266,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# Check that the new IP and user agent has not been stored yet
|
||||
db_result = cast(
|
||||
List[Tuple[str, Optional[str], Optional[str], str, Optional[int]]],
|
||||
list[tuple[str, Optional[str], Optional[str], str, Optional[int]]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="devices",
|
||||
@@ -381,7 +381,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# Check that the new IP and user agent has not been stored yet
|
||||
db_result = cast(
|
||||
List[Tuple[str, str, str, int]],
|
||||
list[tuple[str, str, str, int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -589,7 +589,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# We should see that in the DB
|
||||
result = cast(
|
||||
List[Tuple[str, str, str, Optional[str], int]],
|
||||
list[tuple[str, str, str, Optional[str], int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -616,7 +616,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# We should get no results.
|
||||
result = cast(
|
||||
List[Tuple[str, str, str, Optional[str], int]],
|
||||
list[tuple[str, str, str, Optional[str], int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -695,7 +695,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# We should see that in the DB
|
||||
result = cast(
|
||||
List[Tuple[str, str, str, Optional[str], int]],
|
||||
list[tuple[str, str, str, Optional[str], int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -745,9 +745,9 @@ class ClientIpAuthTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def _runtest(
|
||||
self,
|
||||
headers: Dict[bytes, bytes],
|
||||
headers: dict[bytes, bytes],
|
||||
expected_ip: str,
|
||||
make_request_args: Dict[str, Any],
|
||||
make_request_args: dict[str, Any],
|
||||
) -> None:
|
||||
device_id = "bleb"
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import Callable, Tuple
|
||||
from typing import Callable
|
||||
from unittest.mock import Mock, call
|
||||
|
||||
from twisted.internet import defer
|
||||
@@ -149,7 +149,7 @@ class CallbacksTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def _run_interaction(
|
||||
self, func: Callable[[LoggingTransaction], object]
|
||||
) -> Tuple[Mock, Mock]:
|
||||
) -> tuple[Mock, Mock]:
|
||||
"""Run the given function in a database transaction, with callbacks registered.
|
||||
|
||||
Args:
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import Collection, List, Tuple
|
||||
from typing import Collection
|
||||
|
||||
from twisted.internet.testing import MemoryReactor
|
||||
|
||||
@@ -44,7 +44,7 @@ class DeviceStoreTestCase(HomeserverTestCase):
|
||||
config["federation_sender_instances"] = ["master"]
|
||||
return config
|
||||
|
||||
def add_device_change(self, user_id: str, device_ids: List[str], host: str) -> None:
|
||||
def add_device_change(self, user_id: str, device_ids: list[str], host: str) -> None:
|
||||
"""Add a device list change for the given device to
|
||||
`device_lists_outbound_pokes` table.
|
||||
"""
|
||||
@@ -306,7 +306,7 @@ class DeviceStoreTestCase(HomeserverTestCase):
|
||||
def _check_devices_in_updates(
|
||||
self,
|
||||
expected_device_ids: Collection[str],
|
||||
device_updates: List[Tuple[str, JsonDict]],
|
||||
device_updates: list[tuple[str, JsonDict]],
|
||||
) -> None:
|
||||
"""Check that an specific device ids exist in a list of device update EDUs"""
|
||||
self.assertEqual(len(device_updates), len(expected_device_ids))
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import Dict, List, Set, Tuple, cast
|
||||
from typing import cast
|
||||
|
||||
from parameterized import parameterized
|
||||
|
||||
@@ -420,7 +420,7 @@ class EventChainStoreTestCase(HomeserverTestCase):
|
||||
|
||||
def persist(
|
||||
self,
|
||||
events: List[EventBase],
|
||||
events: list[EventBase],
|
||||
) -> None:
|
||||
"""Persist the given events and check that the links generated match
|
||||
those given.
|
||||
@@ -464,11 +464,11 @@ class EventChainStoreTestCase(HomeserverTestCase):
|
||||
)
|
||||
|
||||
def fetch_chains(
|
||||
self, events: List[EventBase]
|
||||
) -> Tuple[Dict[str, Tuple[int, int]], _LinkMap]:
|
||||
self, events: list[EventBase]
|
||||
) -> tuple[dict[str, tuple[int, int]], _LinkMap]:
|
||||
# Fetch the map from event ID -> (chain ID, sequence number)
|
||||
rows = cast(
|
||||
List[Tuple[str, int, int]],
|
||||
list[tuple[str, int, int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_many_batch(
|
||||
table="event_auth_chains",
|
||||
@@ -487,7 +487,7 @@ class EventChainStoreTestCase(HomeserverTestCase):
|
||||
|
||||
# Fetch all the links and pass them to the _LinkMap.
|
||||
auth_chain_rows = cast(
|
||||
List[Tuple[int, int, int, int]],
|
||||
list[tuple[int, int, int, int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_many_batch(
|
||||
table="event_auth_chain_links",
|
||||
@@ -575,7 +575,7 @@ class EventChainBackgroundUpdateTestCase(HomeserverTestCase):
|
||||
self.token = self.login("foo", "pass")
|
||||
self.requester = create_requester(self.user_id)
|
||||
|
||||
def _generate_room(self) -> Tuple[str, List[Set[str]]]:
|
||||
def _generate_room(self) -> tuple[str, list[set[str]]]:
|
||||
"""Insert a room without a chain cover index."""
|
||||
room_id = self.helper.create_room_as(self.user_id, tok=self.token)
|
||||
|
||||
|
||||
@@ -21,14 +21,9 @@
|
||||
import datetime
|
||||
from typing import (
|
||||
Collection,
|
||||
Dict,
|
||||
FrozenSet,
|
||||
Iterable,
|
||||
List,
|
||||
Mapping,
|
||||
NamedTuple,
|
||||
Set,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
cast,
|
||||
@@ -74,7 +69,7 @@ import tests.utils
|
||||
# | |
|
||||
# K J
|
||||
|
||||
AUTH_GRAPH: Dict[str, List[str]] = {
|
||||
AUTH_GRAPH: dict[str, list[str]] = {
|
||||
"a": ["e"],
|
||||
"b": ["e"],
|
||||
"c": ["g", "i"],
|
||||
@@ -108,7 +103,7 @@ T = TypeVar("T")
|
||||
def get_all_topologically_sorted_orders(
|
||||
nodes: Iterable[T],
|
||||
graph: Mapping[T, Collection[T]],
|
||||
) -> List[List[T]]:
|
||||
) -> list[list[T]]:
|
||||
"""Given a set of nodes and a graph, return all possible topological
|
||||
orderings.
|
||||
"""
|
||||
@@ -117,7 +112,7 @@ def get_all_topologically_sorted_orders(
|
||||
# we have a choice over which node to consider next.
|
||||
|
||||
degree_map = dict.fromkeys(nodes, 0)
|
||||
reverse_graph: Dict[T, Set[T]] = {}
|
||||
reverse_graph: dict[T, set[T]] = {}
|
||||
|
||||
for node, edges in graph.items():
|
||||
if node not in degree_map:
|
||||
@@ -138,10 +133,10 @@ def get_all_topologically_sorted_orders(
|
||||
|
||||
|
||||
def _get_all_topologically_sorted_orders_inner(
|
||||
reverse_graph: Dict[T, Set[T]],
|
||||
zero_degree: List[T],
|
||||
degree_map: Dict[T, int],
|
||||
) -> List[List[T]]:
|
||||
reverse_graph: dict[T, set[T]],
|
||||
zero_degree: list[T],
|
||||
degree_map: dict[T, int],
|
||||
) -> list[list[T]]:
|
||||
new_paths = []
|
||||
|
||||
# Rather than only choosing *one* item from the list of nodes with zero
|
||||
@@ -175,7 +170,7 @@ def _get_all_topologically_sorted_orders_inner(
|
||||
def get_all_topologically_consistent_subsets(
|
||||
nodes: Iterable[T],
|
||||
graph: Mapping[T, Collection[T]],
|
||||
) -> Set[FrozenSet[T]]:
|
||||
) -> set[frozenset[T]]:
|
||||
"""Get all subsets of the graph where if node N is in the subgraph, then all
|
||||
nodes that can reach that node (i.e. for all X there exists a path X -> N)
|
||||
are in the subgraph.
|
||||
@@ -195,7 +190,7 @@ def get_all_topologically_consistent_subsets(
|
||||
@attr.s(auto_attribs=True, frozen=True, slots=True)
|
||||
class _BackfillSetupInfo:
|
||||
room_id: str
|
||||
depth_map: Dict[str, int]
|
||||
depth_map: dict[str, int]
|
||||
|
||||
|
||||
class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase):
|
||||
@@ -573,7 +568,7 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase):
|
||||
# | |
|
||||
# K J
|
||||
|
||||
auth_graph: Dict[str, List[str]] = {
|
||||
auth_graph: dict[str, list[str]] = {
|
||||
"a": ["e"],
|
||||
"b": ["e"],
|
||||
"c": ["g", "i"],
|
||||
@@ -756,11 +751,11 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase):
|
||||
seq_num: int
|
||||
|
||||
class TestLink(NamedTuple):
|
||||
origin_chain_and_seq: Tuple[int, int]
|
||||
target_chain_and_seq: Tuple[int, int]
|
||||
origin_chain_and_seq: tuple[int, int]
|
||||
target_chain_and_seq: tuple[int, int]
|
||||
|
||||
# Map to chain IDs / seq nums
|
||||
nodes: List[TestNode] = [
|
||||
nodes: list[TestNode] = [
|
||||
TestNode("A1", 1, 1),
|
||||
TestNode("A2", 1, 2),
|
||||
TestNode("A3", 1, 3),
|
||||
@@ -779,7 +774,7 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase):
|
||||
TestNode("G1", 7, 1),
|
||||
TestNode("G2", 7, 2),
|
||||
]
|
||||
links: List[TestLink] = [
|
||||
links: list[TestLink] = [
|
||||
TestLink((2, 1), (1, 2)), # B1 -> A2
|
||||
TestLink((3, 1), (2, 2)), # C1 -> B2
|
||||
TestLink((4, 1), (3, 1)), # D1 -> C1
|
||||
@@ -818,9 +813,9 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase):
|
||||
# Define the test cases
|
||||
class TestCase(NamedTuple):
|
||||
name: str
|
||||
conflicted: Set[str]
|
||||
additional_backwards_reachable: Set[str]
|
||||
want_conflicted_subgraph: Set[str]
|
||||
conflicted: set[str]
|
||||
additional_backwards_reachable: set[str]
|
||||
want_conflicted_subgraph: set[str]
|
||||
|
||||
# Reminder:
|
||||
# A1 <- A2 <- A3
|
||||
@@ -936,7 +931,7 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase):
|
||||
|
||||
room_id = "some_room_id"
|
||||
|
||||
def prev_event_format(prev_event_id: str) -> Union[Tuple[str, dict], str]:
|
||||
def prev_event_format(prev_event_id: str) -> Union[tuple[str, dict], str]:
|
||||
"""Account for differences in prev_events format across room versions"""
|
||||
if room_version.event_format == EventFormatVersions.ROOM_V1_V2:
|
||||
return prev_event_id, {}
|
||||
@@ -1034,7 +1029,7 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase):
|
||||
# |
|
||||
# 5 (newest)
|
||||
|
||||
event_graph: Dict[str, List[str]] = {
|
||||
event_graph: dict[str, list[str]] = {
|
||||
"1": [],
|
||||
"2": ["1"],
|
||||
"3": ["2", "A"],
|
||||
@@ -1050,7 +1045,7 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase):
|
||||
"b6": ["3"],
|
||||
}
|
||||
|
||||
depth_map: Dict[str, int] = {
|
||||
depth_map: dict[str, int] = {
|
||||
"1": 1,
|
||||
"2": 2,
|
||||
"b1": 3,
|
||||
@@ -1070,7 +1065,7 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase):
|
||||
# The rest are events in the room but not backfilled tet.
|
||||
our_server_events = {"5", "4", "B", "3", "A"}
|
||||
|
||||
complete_event_dict_map: Dict[str, JsonDict] = {}
|
||||
complete_event_dict_map: dict[str, JsonDict] = {}
|
||||
stream_ordering = 0
|
||||
for event_id, prev_event_ids in event_graph.items():
|
||||
depth = depth_map[event_id]
|
||||
@@ -1425,14 +1420,14 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase):
|
||||
class FakeEvent:
|
||||
event_id: str
|
||||
room_id: str
|
||||
auth_events: List[str]
|
||||
auth_events: list[str]
|
||||
|
||||
type = "foo"
|
||||
state_key = "foo"
|
||||
|
||||
internal_metadata = EventInternalMetadata({})
|
||||
|
||||
def auth_event_ids(self) -> List[str]:
|
||||
def auth_event_ids(self) -> list[str]:
|
||||
return self.auth_events
|
||||
|
||||
def is_state(self) -> bool:
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import Optional, Tuple
|
||||
from typing import Optional
|
||||
|
||||
from twisted.internet.testing import MemoryReactor
|
||||
|
||||
@@ -47,7 +47,7 @@ class EventPushActionsStoreTestCase(HomeserverTestCase):
|
||||
assert persist_events_store is not None
|
||||
self.persist_events_store = persist_events_store
|
||||
|
||||
def _create_users_and_room(self) -> Tuple[str, str, str, str, str]:
|
||||
def _create_users_and_room(self) -> tuple[str, str, str, str, str]:
|
||||
"""
|
||||
Creates two users and a shared room.
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Optional
|
||||
|
||||
from twisted.internet.testing import MemoryReactor
|
||||
|
||||
@@ -54,7 +54,7 @@ class EventsTestCase(HomeserverTestCase):
|
||||
def test_get_senders_for_event_ids(self) -> None:
|
||||
"""Tests the `get_senders_for_event_ids` storage function."""
|
||||
|
||||
users_and_tokens: Dict[str, str] = {}
|
||||
users_and_tokens: dict[str, str] = {}
|
||||
for localpart_suffix in range(10):
|
||||
localpart = f"user_{localpart_suffix}"
|
||||
user_id = self.register_user(localpart, "rabbit")
|
||||
@@ -70,7 +70,7 @@ class EventsTestCase(HomeserverTestCase):
|
||||
room_id = self.helper.create_room_as(
|
||||
room_creator_user_id, tok=room_creator_token
|
||||
)
|
||||
event_ids_to_senders: Dict[str, str] = {}
|
||||
event_ids_to_senders: dict[str, str] = {}
|
||||
for user_id, token in users_and_tokens.items():
|
||||
if user_id == room_creator_user_id:
|
||||
continue
|
||||
@@ -180,7 +180,7 @@ class ExtremPruneTestCase(HomeserverTestCase):
|
||||
)
|
||||
self.get_success(self._persistence.persist_event(event, context))
|
||||
|
||||
def assert_extremities(self, expected_extremities: List[str]) -> None:
|
||||
def assert_extremities(self, expected_extremities: list[str]) -> None:
|
||||
"""Assert the current extremities for the room"""
|
||||
extremities = self.get_success(
|
||||
self.store.get_prev_events_for_room(self.room_id)
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import Dict
|
||||
|
||||
from twisted.internet.testing import MemoryReactor
|
||||
|
||||
@@ -48,7 +47,7 @@ class TestFixupMaxDepthCapBgUpdate(HomeserverTestCase):
|
||||
)
|
||||
)
|
||||
|
||||
def create_room(self, room_version: RoomVersion) -> Dict[str, int]:
|
||||
def create_room(self, room_version: RoomVersion) -> dict[str, int]:
|
||||
"""Create a room with a known room version and insert events.
|
||||
|
||||
Returns the set of event IDs that exceed MAX_DEPTH and
|
||||
@@ -67,7 +66,7 @@ class TestFixupMaxDepthCapBgUpdate(HomeserverTestCase):
|
||||
)
|
||||
|
||||
# Insert events with some depths exceeding MAX_DEPTH
|
||||
event_id_to_depth: Dict[str, int] = {}
|
||||
event_id_to_depth: dict[str, int] = {}
|
||||
for depth in range(MAX_DEPTH - 5, MAX_DEPTH + 5):
|
||||
event_id = f"$event{depth}:example.com"
|
||||
event_id_to_depth[event_id] = depth
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
# [This file includes modifications made by New Vector Limited]
|
||||
#
|
||||
#
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Optional
|
||||
|
||||
from twisted.internet.testing import MemoryReactor
|
||||
|
||||
@@ -43,12 +43,12 @@ from tests.utils import USE_POSTGRES_FOR_TESTS
|
||||
|
||||
class MultiWriterIdGeneratorBase(HomeserverTestCase):
|
||||
positive: bool = True
|
||||
tables: List[str] = ["foobar"]
|
||||
tables: list[str] = ["foobar"]
|
||||
|
||||
def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
|
||||
self.store = hs.get_datastores().main
|
||||
self.db_pool: DatabasePool = self.store.db_pool
|
||||
self.instances: Dict[str, MultiWriterIdGenerator] = {}
|
||||
self.instances: dict[str, MultiWriterIdGenerator] = {}
|
||||
|
||||
self.get_success(self.db_pool.runInteraction("_setup_db", self._setup_db))
|
||||
|
||||
@@ -76,7 +76,7 @@ class MultiWriterIdGeneratorBase(HomeserverTestCase):
|
||||
def _create_id_generator(
|
||||
self,
|
||||
instance_name: str = "master",
|
||||
writers: Optional[List[str]] = None,
|
||||
writers: Optional[list[str]] = None,
|
||||
) -> MultiWriterIdGenerator:
|
||||
def _create(conn: LoggingDatabaseConnection) -> MultiWriterIdGenerator:
|
||||
return MultiWriterIdGenerator(
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# [This file includes modifications made by New Vector Limited]
|
||||
#
|
||||
#
|
||||
from typing import Any, Dict, List
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from twisted.internet.testing import MemoryReactor
|
||||
@@ -32,7 +32,7 @@ from tests.unittest import default_config, override_config
|
||||
FORTY_DAYS = 40 * 24 * 60 * 60
|
||||
|
||||
|
||||
def gen_3pids(count: int) -> List[Dict[str, Any]]:
|
||||
def gen_3pids(count: int) -> list[dict[str, Any]]:
|
||||
"""Generate `count` threepids as a list."""
|
||||
return [
|
||||
{"medium": "email", "address": "user%i@matrix.org" % i} for i in range(count)
|
||||
@@ -40,7 +40,7 @@ def gen_3pids(count: int) -> List[Dict[str, Any]]:
|
||||
|
||||
|
||||
class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
|
||||
def default_config(self) -> Dict[str, Any]:
|
||||
def default_config(self) -> dict[str, Any]:
|
||||
config = default_config("test")
|
||||
|
||||
config.update({"limit_usage_by_mau": True, "max_mau_value": 50})
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
# [This file includes modifications made by New Vector Limited]
|
||||
#
|
||||
#
|
||||
from typing import List, Optional, cast
|
||||
from typing import Optional, cast
|
||||
|
||||
from canonicaljson import json
|
||||
|
||||
@@ -247,8 +247,8 @@ class RedactionTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
async def build(
|
||||
self,
|
||||
prev_event_ids: List[str],
|
||||
auth_event_ids: Optional[List[str]],
|
||||
prev_event_ids: list[str],
|
||||
auth_event_ids: Optional[list[str]],
|
||||
depth: Optional[int] = None,
|
||||
) -> EventBase:
|
||||
built_event = await self._base_builder.build(
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
# [This file includes modifications made by New Vector Limited]
|
||||
#
|
||||
#
|
||||
from typing import List
|
||||
from unittest import mock
|
||||
|
||||
from twisted.internet.testing import MemoryReactor
|
||||
@@ -34,7 +33,7 @@ from synapse.util.clock import Clock
|
||||
from tests.unittest import HomeserverTestCase
|
||||
|
||||
|
||||
def fake_listdir(filepath: str) -> List[str]:
|
||||
def fake_listdir(filepath: str) -> list[str]:
|
||||
"""
|
||||
A fake implementation of os.listdir which we can use to mock out the filesystem.
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import List, Tuple
|
||||
from unittest.case import SkipTest
|
||||
|
||||
from twisted.internet.testing import MemoryReactor
|
||||
@@ -317,7 +316,7 @@ class MessageSearchTest(HomeserverTestCase):
|
||||
)
|
||||
|
||||
def _check_test_cases(
|
||||
self, store: DataStore, cases: List[Tuple[str, bool]]
|
||||
self, store: DataStore, cases: list[tuple[str, bool]]
|
||||
) -> None:
|
||||
# Run all the test cases versus search_msgs
|
||||
for query, expect_to_contain in cases:
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#
|
||||
#
|
||||
import logging
|
||||
from typing import List, Optional, Tuple, cast
|
||||
from typing import Optional, cast
|
||||
|
||||
from twisted.internet.testing import MemoryReactor
|
||||
|
||||
@@ -133,7 +133,7 @@ class RoomMemberStoreTestCase(unittest.HomeserverTestCase):
|
||||
room = self.helper.create_room_as(self.u_alice, tok=self.t_alice)
|
||||
|
||||
res = cast(
|
||||
List[Tuple[Optional[str], str]],
|
||||
list[tuple[Optional[str], str]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
"room_memberships",
|
||||
@@ -165,7 +165,7 @@ class RoomMemberStoreTestCase(unittest.HomeserverTestCase):
|
||||
)
|
||||
|
||||
res2 = cast(
|
||||
List[Tuple[Optional[str], str]],
|
||||
list[tuple[Optional[str], str]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
"room_memberships",
|
||||
@@ -408,7 +408,7 @@ class RoomSummaryTestCase(unittest.HomeserverTestCase):
|
||||
def _assert_member_summary(
|
||||
self,
|
||||
actual_member_summary: MemberSummary,
|
||||
expected_member_list: List[str],
|
||||
expected_member_list: list[str],
|
||||
*,
|
||||
expected_member_count: Optional[int] = None,
|
||||
) -> None:
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#
|
||||
#
|
||||
import logging
|
||||
from typing import Dict, List, Optional, Tuple, cast
|
||||
from typing import Optional, cast
|
||||
|
||||
import attr
|
||||
from parameterized import parameterized
|
||||
@@ -112,7 +112,7 @@ class SlidingSyncTablesTestCaseBase(HomeserverTestCase):
|
||||
|
||||
self.state_handler = self.hs.get_state_handler()
|
||||
|
||||
def _get_sliding_sync_joined_rooms(self) -> Dict[str, _SlidingSyncJoinedRoomResult]:
|
||||
def _get_sliding_sync_joined_rooms(self) -> dict[str, _SlidingSyncJoinedRoomResult]:
|
||||
"""
|
||||
Return the rows from the `sliding_sync_joined_rooms` table.
|
||||
|
||||
@@ -120,7 +120,7 @@ class SlidingSyncTablesTestCaseBase(HomeserverTestCase):
|
||||
Mapping from room_id to _SlidingSyncJoinedRoomResult.
|
||||
"""
|
||||
rows = cast(
|
||||
List[Tuple[str, int, int, str, str, bool, str]],
|
||||
list[tuple[str, int, int, str, str, bool, str]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
"sliding_sync_joined_rooms",
|
||||
@@ -153,7 +153,7 @@ class SlidingSyncTablesTestCaseBase(HomeserverTestCase):
|
||||
|
||||
def _get_sliding_sync_membership_snapshots(
|
||||
self,
|
||||
) -> Dict[Tuple[str, str], _SlidingSyncMembershipSnapshotResult]:
|
||||
) -> dict[tuple[str, str], _SlidingSyncMembershipSnapshotResult]:
|
||||
"""
|
||||
Return the rows from the `sliding_sync_membership_snapshots` table.
|
||||
|
||||
@@ -161,7 +161,7 @@ class SlidingSyncTablesTestCaseBase(HomeserverTestCase):
|
||||
Mapping from the (room_id, user_id) to _SlidingSyncMembershipSnapshotResult.
|
||||
"""
|
||||
rows = cast(
|
||||
List[Tuple[str, str, str, str, str, int, int, bool, str, str, bool, str]],
|
||||
list[tuple[str, str, str, str, str, int, int, bool, str, str, bool, str]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
"sliding_sync_membership_snapshots",
|
||||
@@ -207,8 +207,8 @@ class SlidingSyncTablesTestCaseBase(HomeserverTestCase):
|
||||
def _create_remote_invite_room_for_user(
|
||||
self,
|
||||
invitee_user_id: str,
|
||||
unsigned_invite_room_state: Optional[List[StrippedStateEvent]],
|
||||
) -> Tuple[str, EventBase]:
|
||||
unsigned_invite_room_state: Optional[list[StrippedStateEvent]],
|
||||
) -> tuple[str, EventBase]:
|
||||
"""
|
||||
Create a fake invite for a remote room and persist it.
|
||||
|
||||
@@ -2246,7 +2246,7 @@ class SlidingSyncTablesTestCase(SlidingSyncTablesTestCaseBase):
|
||||
]
|
||||
)
|
||||
def test_non_join_remote_invite_no_stripped_state(
|
||||
self, _description: str, stripped_state: Optional[List[StrippedStateEvent]]
|
||||
self, _description: str, stripped_state: Optional[list[StrippedStateEvent]]
|
||||
) -> None:
|
||||
"""
|
||||
Test remote invite with no stripped state provided shows up in
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
from typing import List, Tuple, cast
|
||||
from typing import cast
|
||||
|
||||
from immutabledict import immutabledict
|
||||
|
||||
@@ -593,7 +593,7 @@ class StateStoreTestCase(HomeserverTestCase):
|
||||
|
||||
# check that only state events are in state_groups, and all state events are in state_groups
|
||||
res = cast(
|
||||
List[Tuple[str]],
|
||||
list[tuple[str]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="state_groups",
|
||||
@@ -618,7 +618,7 @@ class StateStoreTestCase(HomeserverTestCase):
|
||||
for event, context in processed_events_and_context:
|
||||
if event.is_state():
|
||||
state = cast(
|
||||
List[Tuple[str, str]],
|
||||
list[tuple[str, str]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="state_groups_state",
|
||||
@@ -631,7 +631,7 @@ class StateStoreTestCase(HomeserverTestCase):
|
||||
self.assertEqual(event.state_key, state[0][1])
|
||||
|
||||
groups = cast(
|
||||
List[Tuple[str]],
|
||||
list[tuple[str]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="state_group_edges",
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
from typing import List, Tuple
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from immutabledict import immutabledict
|
||||
@@ -150,7 +149,7 @@ class PaginationTestCase(HomeserverTestCase):
|
||||
)
|
||||
self.event_id_none = res["event_id"]
|
||||
|
||||
def _filter_messages(self, filter: JsonDict) -> List[str]:
|
||||
def _filter_messages(self, filter: JsonDict) -> list[str]:
|
||||
"""Make a request to /messages with a filter, returns the chunk of events."""
|
||||
|
||||
events, next_key, _ = self.get_success(
|
||||
@@ -324,7 +323,7 @@ class GetLastEventInRoomBeforeStreamOrderingTestCase(HomeserverTestCase):
|
||||
|
||||
def _send_event_on_instance(
|
||||
self, instance_name: str, room_id: str, access_token: str
|
||||
) -> Tuple[JsonDict, PersistedEventPosition]:
|
||||
) -> tuple[JsonDict, PersistedEventPosition]:
|
||||
"""
|
||||
Send an event in a room and mimic that it was persisted by a specific
|
||||
instance/worker.
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
#
|
||||
import re
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, cast
|
||||
from typing import Any, Optional, cast
|
||||
from unittest import mock
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
@@ -56,21 +56,21 @@ class GetUserDirectoryTables:
|
||||
def __init__(self, store: DataStore):
|
||||
self.store = store
|
||||
|
||||
async def get_users_in_public_rooms(self) -> Set[Tuple[str, str]]:
|
||||
async def get_users_in_public_rooms(self) -> set[tuple[str, str]]:
|
||||
"""Fetch the entire `users_in_public_rooms` table.
|
||||
|
||||
Returns a list of tuples (user_id, room_id) where room_id is public and
|
||||
contains the user with the given id.
|
||||
"""
|
||||
r = cast(
|
||||
List[Tuple[str, str]],
|
||||
list[tuple[str, str]],
|
||||
await self.store.db_pool.simple_select_list(
|
||||
"users_in_public_rooms", None, ("user_id", "room_id")
|
||||
),
|
||||
)
|
||||
return set(r)
|
||||
|
||||
async def get_users_who_share_private_rooms(self) -> Set[Tuple[str, str, str]]:
|
||||
async def get_users_who_share_private_rooms(self) -> set[tuple[str, str, str]]:
|
||||
"""Fetch the entire `users_who_share_private_rooms` table.
|
||||
|
||||
Returns a set of tuples (user_id, other_user_id, room_id) corresponding
|
||||
@@ -78,7 +78,7 @@ class GetUserDirectoryTables:
|
||||
"""
|
||||
|
||||
rows = cast(
|
||||
List[Tuple[str, str, str]],
|
||||
list[tuple[str, str, str]],
|
||||
await self.store.db_pool.simple_select_list(
|
||||
"users_who_share_private_rooms",
|
||||
None,
|
||||
@@ -87,13 +87,13 @@ class GetUserDirectoryTables:
|
||||
)
|
||||
return set(rows)
|
||||
|
||||
async def get_users_in_user_directory(self) -> Set[str]:
|
||||
async def get_users_in_user_directory(self) -> set[str]:
|
||||
"""Fetch the set of users in the `user_directory` table.
|
||||
|
||||
This is useful when checking we've correctly excluded users from the directory.
|
||||
"""
|
||||
result = cast(
|
||||
List[Tuple[str]],
|
||||
list[tuple[str]],
|
||||
await self.store.db_pool.simple_select_list(
|
||||
"user_directory",
|
||||
None,
|
||||
@@ -102,7 +102,7 @@ class GetUserDirectoryTables:
|
||||
)
|
||||
return {row[0] for row in result}
|
||||
|
||||
async def get_profiles_in_user_directory(self) -> Dict[str, ProfileInfo]:
|
||||
async def get_profiles_in_user_directory(self) -> dict[str, ProfileInfo]:
|
||||
"""Fetch users and their profiles from the `user_directory` table.
|
||||
|
||||
This is useful when we want to inspect display names and avatars.
|
||||
@@ -110,7 +110,7 @@ class GetUserDirectoryTables:
|
||||
thing missing is an unused room_id column.
|
||||
"""
|
||||
rows = cast(
|
||||
List[Tuple[str, Optional[str], Optional[str]]],
|
||||
list[tuple[str, Optional[str], Optional[str]]],
|
||||
await self.store.db_pool.simple_select_list(
|
||||
"user_directory",
|
||||
None,
|
||||
@@ -124,7 +124,7 @@ class GetUserDirectoryTables:
|
||||
|
||||
async def get_tables(
|
||||
self,
|
||||
) -> Tuple[Set[str], Set[Tuple[str, str]], Set[Tuple[str, str, str]]]:
|
||||
) -> tuple[set[str], set[tuple[str, str]], set[tuple[str, str, str]]]:
|
||||
"""Multiple tests want to inspect these tables, so expose them together."""
|
||||
return (
|
||||
await self.get_users_in_user_directory(),
|
||||
@@ -277,7 +277,7 @@ class UserDirectoryInitialPopulationTestcase(HomeserverTestCase):
|
||||
|
||||
def _create_rooms_and_inject_memberships(
|
||||
self, creator: str, token: str, joiner: str
|
||||
) -> Tuple[str, str]:
|
||||
) -> tuple[str, str]:
|
||||
"""Create a public and private room as a normal user.
|
||||
Then get the `joiner` into those rooms.
|
||||
"""
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import Collection, Dict
|
||||
from typing import Collection
|
||||
from unittest import mock
|
||||
|
||||
from twisted.internet.defer import CancelledError, ensureDeferred
|
||||
@@ -35,9 +35,9 @@ from tests.unittest import TestCase
|
||||
class PartialStateEventsTrackerTestCase(TestCase):
|
||||
def setUp(self) -> None:
|
||||
# the results to be returned by the mocked get_partial_state_events
|
||||
self._events_dict: Dict[str, bool] = {}
|
||||
self._events_dict: dict[str, bool] = {}
|
||||
|
||||
async def get_partial_state_events(events: Collection[str]) -> Dict[str, bool]:
|
||||
async def get_partial_state_events(events: Collection[str]) -> dict[str, bool]:
|
||||
return {e: self._events_dict[e] for e in events}
|
||||
|
||||
self.mock_store = mock.Mock(spec_set=["get_partial_state_events"])
|
||||
@@ -73,7 +73,7 @@ class PartialStateEventsTrackerTestCase(TestCase):
|
||||
# registration of the listener, it should not block.
|
||||
self._events_dict = {"event1": True, "event2": False}
|
||||
|
||||
async def get_partial_state_events(events: Collection[str]) -> Dict[str, bool]:
|
||||
async def get_partial_state_events(events: Collection[str]) -> dict[str, bool]:
|
||||
res = {e: self._events_dict[e] for e in events}
|
||||
# change the result for next time
|
||||
self._events_dict = {"event1": False, "event2": False}
|
||||
@@ -91,13 +91,13 @@ class PartialStateEventsTrackerTestCase(TestCase):
|
||||
|
||||
self._events_dict = {"event1": True, "event2": False}
|
||||
|
||||
async def get_partial_state_events1(events: Collection[str]) -> Dict[str, bool]:
|
||||
async def get_partial_state_events1(events: Collection[str]) -> dict[str, bool]:
|
||||
self.mock_store.get_partial_state_events.side_effect = (
|
||||
get_partial_state_events2
|
||||
)
|
||||
return {e: self._events_dict[e] for e in events}
|
||||
|
||||
async def get_partial_state_events2(events: Collection[str]) -> Dict[str, bool]:
|
||||
async def get_partial_state_events2(events: Collection[str]) -> dict[str, bool]:
|
||||
self.tracker.notify_un_partial_stated("event1")
|
||||
self._events_dict["event1"] = False
|
||||
return {e: self._events_dict[e] for e in events}
|
||||
|
||||
Reference in New Issue
Block a user