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

Fix mypy error on develop #8282

Merged
merged 3 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8282.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clean up type hints for `PaginationConfig`.
9 changes: 6 additions & 3 deletions synapse/handlers/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,15 @@ async def get_messages(
# case "JOIN" would have been returned.
assert member_event_id

leave_token = await self.store.get_topological_token_for_event(
leave_token_str = await self.store.get_topological_token_for_event(
member_event_id
)
if RoomStreamToken.parse(leave_token).topological < max_topo:
leave_token = RoomStreamToken.parse(leave_token_str)
assert leave_token.topological
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be is not None?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, surely we should be using if+exception here instead of assert? It doesn't look like a condition that's impossible to reach to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_topological_token_for_event should absolutely be returning a token which has a topological part.

I'm not a huge fan of using if + exception for informing mypy about such assumptions, as it has the potential to be quite nosiy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_topological_token_for_event should absolutely be returning a token which has a topological part.

Oh, ignore me, I misread the code.


if leave_token.topological < max_topo:
from_token = from_token.copy_and_replace(
"room_key", leave_token
"room_key", leave_token_str
)

await self.hs.get_handlers().federation_handler.maybe_backfill(
Expand Down