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

Commit 75a70af

Browse files
author
David Robertson
committed
Add an annotation for stream_ordering_month_ago
1 parent 444b231 commit 75a70af

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

synapse/storage/databases/main/event_federation.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ def __init__(self, room_id: str):
114114

115115

116116
class EventFederationWorkerStore(SignatureWorkerStore, EventsWorkerStore, SQLBaseStore):
117+
# TODO: this attribute comes from EventPushActionWorkerStore. Should we inherit from
118+
# that store so that mypy can deduce this for itself?
119+
stream_ordering_month_ago: Optional[int]
120+
117121
def __init__(
118122
self,
119123
database: DatabasePool,
@@ -1182,8 +1186,8 @@ async def have_room_forward_extremities_changed_since(
11821186
Throws a StoreError if we have since purged the index for
11831187
stream_orderings from that point.
11841188
"""
1185-
1186-
if stream_ordering <= self.stream_ordering_month_ago: # type: ignore[attr-defined]
1189+
assert self.stream_ordering_month_ago is not None
1190+
if stream_ordering <= self.stream_ordering_month_ago:
11871191
raise StoreError(400, f"stream_ordering too old {stream_ordering}")
11881192

11891193
sql = """
@@ -1231,7 +1235,8 @@ async def get_forward_extremities_for_room_at_stream_ordering(
12311235

12321236
# provided the last_change is recent enough, we now clamp the requested
12331237
# stream_ordering to it.
1234-
if last_change > self.stream_ordering_month_ago: # type: ignore[attr-defined]
1238+
assert self.stream_ordering_month_ago is not None
1239+
if last_change > self.stream_ordering_month_ago:
12351240
stream_ordering = min(last_change, stream_ordering)
12361241

12371242
return await self._get_forward_extremeties_for_room(room_id, stream_ordering)
@@ -1246,8 +1251,8 @@ async def _get_forward_extremeties_for_room(
12461251
Throws a StoreError if we have since purged the index for
12471252
stream_orderings from that point.
12481253
"""
1249-
1250-
if stream_ordering <= self.stream_ordering_month_ago: # type: ignore[attr-defined]
1254+
assert self.stream_ordering_month_ago is not None
1255+
if stream_ordering <= self.stream_ordering_month_ago:
12511256
raise StoreError(400, "stream_ordering too old %s" % (stream_ordering,))
12521257

12531258
sql = """
@@ -1707,9 +1712,7 @@ def _delete_old_forward_extrem_cache_txn(txn: LoggingTransaction) -> None:
17071712
DELETE FROM stream_ordering_to_exterm
17081713
WHERE stream_ordering < ?
17091714
"""
1710-
txn.execute(
1711-
sql, (self.stream_ordering_month_ago,) # type: ignore[attr-defined]
1712-
)
1715+
txn.execute(sql, (self.stream_ordering_month_ago,))
17131716

17141717
await self.db_pool.runInteraction(
17151718
"_delete_old_forward_extrem_cache",

0 commit comments

Comments
 (0)