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

Commit ad30ac9

Browse files
author
Sean Quah
committed
Accept Collections instead of Lists in EventCreationHandler.create_event
Signed-off-by: Sean Quah <[email protected]>
1 parent bcb930a commit ad30ac9

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

synapse/events/builder.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import logging
15-
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
15+
from typing import TYPE_CHECKING, Any, Collection, Dict, List, Optional, Tuple, Union
1616

1717
import attr
1818
from signedjson.types import SigningKey
@@ -101,8 +101,8 @@ def is_state(self) -> bool:
101101

102102
async def build(
103103
self,
104-
prev_event_ids: List[str],
105-
auth_event_ids: Optional[List[str]],
104+
prev_event_ids: Collection[str],
105+
auth_event_ids: Optional[Collection[str]],
106106
depth: Optional[int] = None,
107107
) -> EventBase:
108108
"""Transform into a fully signed and hashed event
@@ -135,8 +135,8 @@ async def build(
135135
auth_events = await self._store.add_event_hashes(auth_event_ids)
136136
prev_events = await self._store.add_event_hashes(prev_event_ids)
137137
else:
138-
auth_events = auth_event_ids
139-
prev_events = prev_event_ids
138+
auth_events = list(auth_event_ids)
139+
prev_events = list(prev_event_ids)
140140

141141
# Otherwise, progress the depth as normal
142142
if depth is None:

synapse/handlers/message.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import logging
1818
import random
1919
from http import HTTPStatus
20-
from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Tuple
20+
from typing import TYPE_CHECKING, Any, Collection, Dict, List, Mapping, Optional, Tuple
2121

2222
from canonicaljson import encode_canonical_json
2323

@@ -487,9 +487,9 @@ async def create_event(
487487
event_dict: dict,
488488
txn_id: Optional[str] = None,
489489
allow_no_prev_events: bool = False,
490-
prev_event_ids: Optional[List[str]] = None,
491-
auth_event_ids: Optional[List[str]] = None,
492-
state_event_ids: Optional[List[str]] = None,
490+
prev_event_ids: Optional[Collection[str]] = None,
491+
auth_event_ids: Optional[Collection[str]] = None,
492+
state_event_ids: Optional[Collection[str]] = None,
493493
require_consent: bool = True,
494494
outlier: bool = False,
495495
historical: bool = False,
@@ -901,9 +901,9 @@ async def create_new_client_event(
901901
builder: EventBuilder,
902902
requester: Optional[Requester] = None,
903903
allow_no_prev_events: bool = False,
904-
prev_event_ids: Optional[List[str]] = None,
905-
auth_event_ids: Optional[List[str]] = None,
906-
state_event_ids: Optional[List[str]] = None,
904+
prev_event_ids: Optional[Collection[str]] = None,
905+
auth_event_ids: Optional[Collection[str]] = None,
906+
state_event_ids: Optional[Collection[str]] = None,
907907
depth: Optional[int] = None,
908908
) -> Tuple[EventBase, EventContext]:
909909
"""Create a new event for a local client

synapse/storage/databases/main/event_federation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ def get_insertion_event_backward_extremities_in_room_txn(txn, room_id):
788788
room_id,
789789
)
790790

791-
async def get_max_depth_of(self, event_ids: List[str]) -> Tuple[str, int]:
791+
async def get_max_depth_of(self, event_ids: Iterable[str]) -> Tuple[str, int]:
792792
"""Returns the event ID and depth for the event that has the max depth from a set of event IDs
793793
794794
Args:
@@ -817,7 +817,7 @@ async def get_max_depth_of(self, event_ids: List[str]) -> Tuple[str, int]:
817817

818818
return max_depth_event_id, current_max_depth
819819

820-
async def get_min_depth_of(self, event_ids: List[str]) -> Tuple[str, int]:
820+
async def get_min_depth_of(self, event_ids: Iterable[str]) -> Tuple[str, int]:
821821
"""Returns the event ID and depth for the event that has the min depth from a set of event IDs
822822
823823
Args:

0 commit comments

Comments
 (0)