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

Commit 632ee75

Browse files
committed
some fixes
1 parent 467b136 commit 632ee75

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

synapse/handlers/sync.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,11 @@ async def current_sync_for_user(
410410
set_tag(SynapseTags.SYNC_RESULT, bool(sync_result))
411411
return sync_result
412412

413-
async def push_rules_for_user(self, user: UserID) -> JsonDict:
413+
async def push_rules_for_user(self, user: UserID) -> Dict[str, Dict[str, list]]:
414414
user_id = user.to_string()
415415
rules = await self.store.get_push_rules_for_user(user_id)
416-
rules = format_push_rules_for_user(user, rules)
417-
return rules
416+
result = format_push_rules_for_user(user, rules)
417+
return result
418418

419419
async def ephemeral_by_room(
420420
self,

synapse/storage/databases/main/metrics.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _count_messages(txn: LoggingTransaction) -> int:
133133
"""
134134

135135
txn.execute(sql, (like_clause, self.stream_ordering_day_ago))
136-
(count,) = txn.fetchone()
136+
(count,) = cast(Tuple[int], txn.fetchone())
137137
return count
138138

139139
return await self.db_pool.runInteraction(
@@ -189,7 +189,7 @@ def _count_messages(txn: LoggingTransaction) -> int:
189189
"""
190190

191191
txn.execute(sql, (like_clause, self.stream_ordering_day_ago))
192-
(count,) = txn.fetchone()
192+
(count,) = cast(Tuple[int], txn.fetchone())
193193
return count
194194

195195
return await self.db_pool.runInteraction(

synapse/storage/databases/main/push_rule.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def have_push_rules_changed_txn(txn: LoggingTransaction) -> bool:
199199
" WHERE user_id = ? AND ? < stream_id"
200200
)
201201
txn.execute(sql, (user_id, last_id))
202-
(count,) = txn.fetchone()
202+
(count,) = cast(Tuple[int], txn.fetchone())
203203
return bool(count)
204204

205205
return await self.db_pool.runInteraction(
@@ -345,7 +345,7 @@ async def get_all_push_rule_updates(
345345
return [], current_id, False
346346

347347
def get_all_push_rule_updates_txn(
348-
txn: LoggingTransaction
348+
txn: LoggingTransaction,
349349
) -> Tuple[List[Tuple[int, tuple]], int, bool]:
350350
sql = """
351351
SELECT stream_id, user_id

synapse/storage/databases/main/roommember.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
ProfileInfo,
5252
RoomsForUser,
5353
)
54-
from synapse.types import JsonDict, PersistedEventPosition, StateMap, get_domain_from_id
54+
from synapse.types import PersistedEventPosition, StateMap, get_domain_from_id
5555
from synapse.util.async_helpers import Linearizer
5656
from synapse.util.caches import intern_string
5757
from synapse.util.caches.descriptors import _CacheContext, cached, cachedList
@@ -189,9 +189,7 @@ async def get_users_in_room(self, room_id: str) -> List[str]:
189189
"get_users_in_room", self.get_users_in_room_txn, room_id
190190
)
191191

192-
def get_users_in_room_txn(
193-
self, txn: LoggingTransaction, room_id: str
194-
) -> List[str]:
192+
def get_users_in_room_txn(self, txn: LoggingTransaction, room_id: str) -> List[str]:
195193
# If we can assume current_state_events.membership is up to date
196194
# then we can avoid a join, which is a Very Good Thing given how
197195
# frequently this function gets called.
@@ -232,7 +230,7 @@ async def get_users_in_room_with_profiles(
232230
"""
233231

234232
def _get_users_in_room_with_profiles(
235-
txn: LoggingTransaction
233+
txn: LoggingTransaction,
236234
) -> Dict[str, ProfileInfo]:
237235
sql = """
238236
SELECT state_key, display_name, avatar_url FROM room_memberships as m
@@ -672,7 +670,7 @@ async def get_users_who_share_room_with_user(
672670
async def get_joined_users_from_context(
673671
self, event: EventBase, context: EventContext
674672
) -> Dict[str, ProfileInfo]:
675-
state_group: Union[object, Optional[int]] = context.state_group
673+
state_group = context.state_group
676674
if not state_group:
677675
# If state_group is None it means it has yet to be assigned a
678676
# state group, i.e. we need to make sure that calls with a state_group
@@ -1271,9 +1269,9 @@ def _background_current_state_membership_txn(
12711269

12721270

12731271
class RoomMemberStore(
1274-
RoomMemberWorkerStore,
1275-
RoomMemberBackgroundUpdateStore,
1276-
CacheInvalidationWorkerStore,
1272+
RoomMemberWorkerStore,
1273+
RoomMemberBackgroundUpdateStore,
1274+
CacheInvalidationWorkerStore,
12771275
):
12781276
def __init__(
12791277
self,

0 commit comments

Comments
 (0)