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

Commit c7fe32e

Browse files
authored
Add type hints to synapse/storage/databases/main/room.py (#11575)
1 parent f901f8b commit c7fe32e

File tree

5 files changed

+108
-77
lines changed

5 files changed

+108
-77
lines changed

changelog.d/11575.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add missing type hints to storage classes.

mypy.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ exclude = (?x)
3737
|synapse/storage/databases/main/purge_events.py
3838
|synapse/storage/databases/main/push_rule.py
3939
|synapse/storage/databases/main/receipts.py
40-
|synapse/storage/databases/main/room.py
4140
|synapse/storage/databases/main/roommember.py
4241
|synapse/storage/databases/main/search.py
4342
|synapse/storage/databases/main/state.py
@@ -205,6 +204,9 @@ disallow_untyped_defs = True
205204
[mypy-synapse.storage.databases.main.events_worker]
206205
disallow_untyped_defs = True
207206

207+
[mypy-synapse.storage.databases.main.room]
208+
disallow_untyped_defs = True
209+
208210
[mypy-synapse.storage.databases.main.room_batch]
209211
disallow_untyped_defs = True
210212

synapse/handlers/room_member.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ async def transfer_room_state_on_room_upgrade(
10201020
# Add new room to the room directory if the old room was there
10211021
# Remove old room from the room directory
10221022
old_room = await self.store.get_room(old_room_id)
1023-
if old_room and old_room["is_public"]:
1023+
if old_room is not None and old_room["is_public"]:
10241024
await self.store.set_room_is_public(old_room_id, False)
10251025
await self.store.set_room_is_public(room_id, True)
10261026

@@ -1031,7 +1031,9 @@ async def transfer_room_state_on_room_upgrade(
10311031
local_group_ids = await self.store.get_local_groups_for_room(old_room_id)
10321032
for group_id in local_group_ids:
10331033
# Add new the new room to those groups
1034-
await self.store.add_room_to_group(group_id, room_id, old_room["is_public"])
1034+
await self.store.add_room_to_group(
1035+
group_id, room_id, old_room is not None and old_room["is_public"]
1036+
)
10351037

10361038
# Remove the old room from those groups
10371039
await self.store.remove_room_from_group(group_id, old_room_id)

synapse/storage/databases/main/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ def __init__(
149149
],
150150
)
151151

152-
self._event_reports_id_gen = IdGenerator(db_conn, "event_reports", "id")
153152
self._push_rule_id_gen = IdGenerator(db_conn, "push_rules", "id")
154153
self._push_rules_enable_id_gen = IdGenerator(db_conn, "push_rules_enable", "id")
155154
self._group_updates_id_gen = StreamIdGenerator(

0 commit comments

Comments
 (0)