|
20 | 20 | import logging |
21 | 21 | from enum import Enum |
22 | 22 | from http import HTTPStatus |
23 | | -from typing import ( |
24 | | - TYPE_CHECKING, |
25 | | - Collection, |
26 | | - Dict, |
27 | | - Iterable, |
28 | | - List, |
29 | | - Optional, |
30 | | - Set, |
31 | | - Tuple, |
32 | | - Union, |
33 | | -) |
| 23 | +from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Set, Tuple, Union |
34 | 24 |
|
35 | 25 | import attr |
36 | 26 | from prometheus_client import Histogram |
|
70 | 60 | ) |
71 | 61 | from synapse.storage.databases.main.events import PartialStateConflictError |
72 | 62 | from synapse.storage.databases.main.events_worker import EventRedactBehaviour |
73 | | -from synapse.types import JsonDict, get_domain_from_id |
| 63 | +from synapse.types import JsonDict, StrCollection, get_domain_from_id |
74 | 64 | from synapse.types.state import StateFilter |
75 | 65 | from synapse.util.async_helpers import Linearizer |
76 | 66 | from synapse.util.retryutils import NotRetryingDestination |
@@ -179,7 +169,7 @@ def __init__(self, hs: "HomeServer"): |
179 | 169 | # A dictionary mapping room IDs to (initial destination, other destinations) |
180 | 170 | # tuples. |
181 | 171 | self._partial_state_syncs_maybe_needing_restart: Dict[ |
182 | | - str, Tuple[Optional[str], Collection[str]] |
| 172 | + str, Tuple[Optional[str], StrCollection] |
183 | 173 | ] = {} |
184 | 174 | # A lock guarding the partial state flag for rooms. |
185 | 175 | # When the lock is held for a given room, no other concurrent code may |
@@ -437,7 +427,7 @@ async def _maybe_backfill_inner( |
437 | 427 | ) |
438 | 428 | ) |
439 | 429 |
|
440 | | - async def try_backfill(domains: Collection[str]) -> bool: |
| 430 | + async def try_backfill(domains: StrCollection) -> bool: |
441 | 431 | # TODO: Should we try multiple of these at a time? |
442 | 432 |
|
443 | 433 | # Number of contacted remote homeservers that have denied our backfill |
@@ -1730,7 +1720,7 @@ async def _resume_partial_state_room_sync(self) -> None: |
1730 | 1720 | def _start_partial_state_room_sync( |
1731 | 1721 | self, |
1732 | 1722 | initial_destination: Optional[str], |
1733 | | - other_destinations: Collection[str], |
| 1723 | + other_destinations: StrCollection, |
1734 | 1724 | room_id: str, |
1735 | 1725 | ) -> None: |
1736 | 1726 | """Starts the background process to resync the state of a partial state room, |
@@ -1812,7 +1802,7 @@ async def _sync_partial_state_room_wrapper() -> None: |
1812 | 1802 | async def _sync_partial_state_room( |
1813 | 1803 | self, |
1814 | 1804 | initial_destination: Optional[str], |
1815 | | - other_destinations: Collection[str], |
| 1805 | + other_destinations: StrCollection, |
1816 | 1806 | room_id: str, |
1817 | 1807 | ) -> None: |
1818 | 1808 | """Background process to resync the state of a partial-state room |
@@ -1949,9 +1939,9 @@ async def _sync_partial_state_room( |
1949 | 1939 |
|
1950 | 1940 | def _prioritise_destinations_for_partial_state_resync( |
1951 | 1941 | initial_destination: Optional[str], |
1952 | | - other_destinations: Collection[str], |
| 1942 | + other_destinations: StrCollection, |
1953 | 1943 | room_id: str, |
1954 | | -) -> Collection[str]: |
| 1944 | +) -> StrCollection: |
1955 | 1945 | """Work out the order in which we should ask servers to resync events. |
1956 | 1946 |
|
1957 | 1947 | If an `initial_destination` is given, it takes top priority. Otherwise |
|
0 commit comments