Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit d56202b

Browse files
authored
Fix type of events in StateGroupStorage and StateHandler (#12156)
We make multiple passes over this, so a regular iterable won't do.
1 parent 8533c8b commit d56202b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

changelog.d/12156.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix some type annotations.

synapse/state/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ async def get_current_state(
194194
}
195195

196196
async def get_current_state_ids(
197-
self, room_id: str, latest_event_ids: Optional[Iterable[str]] = None
197+
self, room_id: str, latest_event_ids: Optional[Collection[str]] = None
198198
) -> StateMap[str]:
199199
"""Get the current state, or the state at a set of events, for a room
200200
@@ -243,7 +243,7 @@ async def get_current_hosts_in_room(self, room_id: str) -> Set[str]:
243243
return await self.get_hosts_in_room_at_events(room_id, event_ids)
244244

245245
async def get_hosts_in_room_at_events(
246-
self, room_id: str, event_ids: Iterable[str]
246+
self, room_id: str, event_ids: Collection[str]
247247
) -> Set[str]:
248248
"""Get the hosts that were in a room at the given event ids
249249
@@ -404,7 +404,7 @@ async def compute_event_context(
404404

405405
@measure_func()
406406
async def resolve_state_groups_for_events(
407-
self, room_id: str, event_ids: Iterable[str]
407+
self, room_id: str, event_ids: Collection[str]
408408
) -> _StateCacheEntry:
409409
"""Given a list of event_ids this method fetches the state at each
410410
event, resolves conflicts between them and returns them.

synapse/storage/state.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ async def get_state_group_delta(
561561
return state_group_delta.prev_group, state_group_delta.delta_ids
562562

563563
async def get_state_groups_ids(
564-
self, _room_id: str, event_ids: Iterable[str]
564+
self, _room_id: str, event_ids: Collection[str]
565565
) -> Dict[int, MutableStateMap[str]]:
566566
"""Get the event IDs of all the state for the state groups for the given events
567567
@@ -596,7 +596,7 @@ async def get_state_ids_for_group(self, state_group: int) -> StateMap[str]:
596596
return group_to_state[state_group]
597597

598598
async def get_state_groups(
599-
self, room_id: str, event_ids: Iterable[str]
599+
self, room_id: str, event_ids: Collection[str]
600600
) -> Dict[int, List[EventBase]]:
601601
"""Get the state groups for the given list of event_ids
602602
@@ -648,7 +648,7 @@ def _get_state_groups_from_groups(
648648
return self.stores.state._get_state_groups_from_groups(groups, state_filter)
649649

650650
async def get_state_for_events(
651-
self, event_ids: Iterable[str], state_filter: Optional[StateFilter] = None
651+
self, event_ids: Collection[str], state_filter: Optional[StateFilter] = None
652652
) -> Dict[str, StateMap[EventBase]]:
653653
"""Given a list of event_ids and type tuples, return a list of state
654654
dicts for each event.
@@ -684,7 +684,7 @@ async def get_state_for_events(
684684
return {event: event_to_state[event] for event in event_ids}
685685

686686
async def get_state_ids_for_events(
687-
self, event_ids: Iterable[str], state_filter: Optional[StateFilter] = None
687+
self, event_ids: Collection[str], state_filter: Optional[StateFilter] = None
688688
) -> Dict[str, StateMap[str]]:
689689
"""
690690
Get the state dicts corresponding to a list of events, containing the event_ids

0 commit comments

Comments
 (0)