This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Incorrect type annotation in get_stream_id_for_event_txn
#12437
Labels
good first issue
Good for newcomers
P4
(OBSOLETE: use S- labels.) Okay backlog: will not schedule, will accept patches
T-Task
Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
Originally from this comment thread.
StreamWorkerStore.get_stream_id_for_event_txn
is declared to return anint
. If you call it withallow_none=True
, it returnsNone
, which contravenes the type hints. I think this behaviour is intentional and the type hint is incorrect, judging by how it's used. We only callget_stream_id_for_event_txn
in two places, both in this function:synapse/synapse/storage/databases/main/event_push_actions.py
Lines 184 to 216 in 3e0536c
In particular line 194 of the quoted source looks like it's expecting
stream_ordering
to be possibly None.Given the above, I think the right thing to do is
get_stream_id_for_event_txn
to returnOptional[int]
instead ofint
.EventPushActionsWorkerStore
to inherit fromStreamWorkerStore
and removing the type-ignores where we callget_stream_id_for_event_txn
. Doing so might fail due with DataStore MRO problems (related: Improve type hints for data store usage #11165 and more generally our storage classes are hella confusing #11733). If so, that's fine and we can leave things as they are.The text was updated successfully, but these errors were encountered: