mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 21:33:53 +01:00
Re-type hint some collections in /sync
code as read-only (#13754)
Signed-off-by: Sean Quah <seanq@matrix.org>
This commit is contained in:
parent
5261d2e2e8
commit
69fa29700e
2 changed files with 11 additions and 10 deletions
1
changelog.d/13754.misc
Normal file
1
changelog.d/13754.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Re-type hint some collections as read-only.
|
|
@ -15,6 +15,7 @@ import itertools
|
||||||
import logging
|
import logging
|
||||||
from typing import (
|
from typing import (
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
|
AbstractSet,
|
||||||
Any,
|
Any,
|
||||||
Collection,
|
Collection,
|
||||||
Dict,
|
Dict,
|
||||||
|
@ -1413,10 +1414,10 @@ class SyncHandler:
|
||||||
async def _generate_sync_entry_for_device_list(
|
async def _generate_sync_entry_for_device_list(
|
||||||
self,
|
self,
|
||||||
sync_result_builder: "SyncResultBuilder",
|
sync_result_builder: "SyncResultBuilder",
|
||||||
newly_joined_rooms: Set[str],
|
newly_joined_rooms: AbstractSet[str],
|
||||||
newly_joined_or_invited_or_knocked_users: Set[str],
|
newly_joined_or_invited_or_knocked_users: AbstractSet[str],
|
||||||
newly_left_rooms: Set[str],
|
newly_left_rooms: AbstractSet[str],
|
||||||
newly_left_users: Set[str],
|
newly_left_users: AbstractSet[str],
|
||||||
) -> DeviceListUpdates:
|
) -> DeviceListUpdates:
|
||||||
"""Generate the DeviceListUpdates section of sync
|
"""Generate the DeviceListUpdates section of sync
|
||||||
|
|
||||||
|
@ -1434,8 +1435,7 @@ class SyncHandler:
|
||||||
user_id = sync_result_builder.sync_config.user.to_string()
|
user_id = sync_result_builder.sync_config.user.to_string()
|
||||||
since_token = sync_result_builder.since_token
|
since_token = sync_result_builder.since_token
|
||||||
|
|
||||||
# We're going to mutate these fields, so lets copy them rather than
|
# Take a copy since these fields will be mutated later.
|
||||||
# assume they won't get used later.
|
|
||||||
newly_joined_or_invited_or_knocked_users = set(
|
newly_joined_or_invited_or_knocked_users = set(
|
||||||
newly_joined_or_invited_or_knocked_users
|
newly_joined_or_invited_or_knocked_users
|
||||||
)
|
)
|
||||||
|
@ -1635,8 +1635,8 @@ class SyncHandler:
|
||||||
async def _generate_sync_entry_for_presence(
|
async def _generate_sync_entry_for_presence(
|
||||||
self,
|
self,
|
||||||
sync_result_builder: "SyncResultBuilder",
|
sync_result_builder: "SyncResultBuilder",
|
||||||
newly_joined_rooms: Set[str],
|
newly_joined_rooms: AbstractSet[str],
|
||||||
newly_joined_or_invited_users: Set[str],
|
newly_joined_or_invited_users: AbstractSet[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Generates the presence portion of the sync response. Populates the
|
"""Generates the presence portion of the sync response. Populates the
|
||||||
`sync_result_builder` with the result.
|
`sync_result_builder` with the result.
|
||||||
|
@ -1694,7 +1694,7 @@ class SyncHandler:
|
||||||
self,
|
self,
|
||||||
sync_result_builder: "SyncResultBuilder",
|
sync_result_builder: "SyncResultBuilder",
|
||||||
account_data_by_room: Dict[str, Dict[str, JsonDict]],
|
account_data_by_room: Dict[str, Dict[str, JsonDict]],
|
||||||
) -> Tuple[Set[str], Set[str], Set[str], Set[str]]:
|
) -> Tuple[AbstractSet[str], AbstractSet[str], AbstractSet[str], AbstractSet[str]]:
|
||||||
"""Generates the rooms portion of the sync response. Populates the
|
"""Generates the rooms portion of the sync response. Populates the
|
||||||
`sync_result_builder` with the result.
|
`sync_result_builder` with the result.
|
||||||
|
|
||||||
|
@ -2534,7 +2534,7 @@ class SyncResultBuilder:
|
||||||
archived: List[ArchivedSyncResult] = attr.Factory(list)
|
archived: List[ArchivedSyncResult] = attr.Factory(list)
|
||||||
to_device: List[JsonDict] = attr.Factory(list)
|
to_device: List[JsonDict] = attr.Factory(list)
|
||||||
|
|
||||||
def calculate_user_changes(self) -> Tuple[Set[str], Set[str]]:
|
def calculate_user_changes(self) -> Tuple[AbstractSet[str], AbstractSet[str]]:
|
||||||
"""Work out which other users have joined or left rooms we are joined to.
|
"""Work out which other users have joined or left rooms we are joined to.
|
||||||
|
|
||||||
This data only is only useful for an incremental sync.
|
This data only is only useful for an incremental sync.
|
||||||
|
|
Loading…
Reference in a new issue