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

Commit a85dde3

Browse files
authored
Minor typing fixes (#12034)
These started failing in #12031... I'm a bit mystified by how they ever worked.
1 parent 7c82da2 commit a85dde3

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

changelog.d/12034.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Minor typing fixes.

synapse/federation/sender/per_destination_queue.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,9 @@ async def _catch_up_transmission_loop(self) -> None:
381381
)
382382
)
383383

384-
if self._last_successful_stream_ordering is None:
384+
last_successful_stream_ordering = self._last_successful_stream_ordering
385+
386+
if last_successful_stream_ordering is None:
385387
# if it's still None, then this means we don't have the information
386388
# in our database ­ we haven't successfully sent a PDU to this server
387389
# (at least since the introduction of the feature tracking
@@ -394,16 +396,15 @@ async def _catch_up_transmission_loop(self) -> None:
394396
# get at most 50 catchup room/PDUs
395397
while True:
396398
event_ids = await self._store.get_catch_up_room_event_ids(
397-
self._destination,
398-
self._last_successful_stream_ordering,
399+
self._destination, last_successful_stream_ordering
399400
)
400401

401402
if not event_ids:
402403
# No more events to catch up on, but we can't ignore the chance
403404
# of a race condition, so we check that no new events have been
404405
# skipped due to us being in catch-up mode
405406

406-
if self._catchup_last_skipped > self._last_successful_stream_ordering:
407+
if self._catchup_last_skipped > last_successful_stream_ordering:
407408
# another event has been skipped because we were in catch-up mode
408409
continue
409410

@@ -470,7 +471,7 @@ async def _catch_up_transmission_loop(self) -> None:
470471
# offline
471472
if (
472473
p.internal_metadata.stream_ordering
473-
< self._last_successful_stream_ordering
474+
< last_successful_stream_ordering
474475
):
475476
continue
476477

@@ -513,12 +514,11 @@ async def _catch_up_transmission_loop(self) -> None:
513514
# from the *original* PDU, rather than the PDU(s) we actually
514515
# send. This is because we use it to mark our position in the
515516
# queue of missed PDUs to process.
516-
self._last_successful_stream_ordering = (
517-
pdu.internal_metadata.stream_ordering
518-
)
517+
last_successful_stream_ordering = pdu.internal_metadata.stream_ordering
519518

519+
self._last_successful_stream_ordering = last_successful_stream_ordering
520520
await self._store.set_destination_last_successful_stream_ordering(
521-
self._destination, self._last_successful_stream_ordering
521+
self._destination, last_successful_stream_ordering
522522
)
523523

524524
def _get_rr_edus(self, force_flush: bool) -> Iterable[Edu]:

synapse/handlers/message.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,11 @@ async def create_event(
550550

551551
if event_dict["type"] == EventTypes.Create and event_dict["state_key"] == "":
552552
room_version_id = event_dict["content"]["room_version"]
553-
room_version_obj = KNOWN_ROOM_VERSIONS.get(room_version_id)
554-
if not room_version_obj:
553+
maybe_room_version_obj = KNOWN_ROOM_VERSIONS.get(room_version_id)
554+
if not maybe_room_version_obj:
555555
# this can happen if support is withdrawn for a room version
556556
raise UnsupportedRoomVersionError(room_version_id)
557+
room_version_obj = maybe_room_version_obj
557558
else:
558559
try:
559560
room_version_obj = await self.store.get_room_version(
@@ -1145,12 +1146,13 @@ async def handle_new_client_event(
11451146
room_version_id = event.content.get(
11461147
"room_version", RoomVersions.V1.identifier
11471148
)
1148-
room_version_obj = KNOWN_ROOM_VERSIONS.get(room_version_id)
1149-
if not room_version_obj:
1149+
maybe_room_version_obj = KNOWN_ROOM_VERSIONS.get(room_version_id)
1150+
if not maybe_room_version_obj:
11501151
raise UnsupportedRoomVersionError(
11511152
"Attempt to create a room with unsupported room version %s"
11521153
% (room_version_id,)
11531154
)
1155+
room_version_obj = maybe_room_version_obj
11541156
else:
11551157
room_version_obj = await self.store.get_room_version(event.room_id)
11561158

synapse/handlers/register.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ async def register_user(
320320
if fail_count > 10:
321321
raise SynapseError(500, "Unable to find a suitable guest user ID")
322322

323-
localpart = await self.store.generate_user_id()
324-
user = UserID(localpart, self.hs.hostname)
323+
generated_localpart = await self.store.generate_user_id()
324+
user = UserID(generated_localpart, self.hs.hostname)
325325
user_id = user.to_string()
326326
self.check_user_id_not_appservice_exclusive(user_id)
327327
if generate_display_name:
328-
default_display_name = localpart
328+
default_display_name = generated_localpart
329329
try:
330330
await self.register_with_store(
331331
user_id=user_id,

0 commit comments

Comments
 (0)