fix type annotation in get_stream_id_for_event_txn#12470
fix type annotation in get_stream_id_for_event_txn#12470gautamgiri-dev wants to merge 4 commits into
get_stream_id_for_event_txn#12470Conversation
get_stream_id_for_event_txn
DMRobertson
left a comment
There was a problem hiding this comment.
Hi @gautamgiri-dev. Thanks for taking this on. There are some problems I've outlined below. Can you also please run the linter script? See https://matrix-org.github.io/synapse/develop/code_style.html for instructions.
| @overload | ||
| @classmethod | ||
| def simple_select_one_onecol_txn( | ||
| cls, | ||
| txn: LoggingTransaction, | ||
| table: str, | ||
| keyvalues: Dict[str, Any], | ||
| retcol: str, | ||
| allow_none: bool = False, | ||
| ) -> Optional[int]: | ||
| ret = cls.simple_select_one_onecol_txn(cls, txn, table=table, keyvalues=keyvalues, retcol=retcol, allow_none=allow_none) | ||
| if ret: | ||
| return int(ret) | ||
| return ret |
There was a problem hiding this comment.
This doesn't look right --- @overloads should not have an implementation; they should be for type hints only. See https://mypy.readthedocs.io/en/stable/more_types.html#function-overloading for more details.
Furthermore this is a generic function and there is no particular reason this should return an int. Additionally, the call to cls.simple_select_one_onecol_txn would infinitely recurse.
Can you explain your thinking here? What error was this attempting to address?
|
|
||
| if last_read_event_id is not None: | ||
| stream_ordering = self.get_stream_id_for_event_txn( # type: ignore[attr-defined] | ||
| stream_ordering = self.get_stream_id_for_event_txn( |
There was a problem hiding this comment.
As I mentioned in #12437, for this to have any chance of working we need to change the class EventPushActionsWorkerStore to inherit from StreamWorkerStore: see my point 2 there.
Note that this may end up causing runtime failures if we run into MRO problems. If that's the case, CI will detect this.
|
I think this got done in #12716. |
Fixes: #12437
StreamWorkerStore.get_stream_id_for_event_txnnow has return typeOptional[int]which is consistent with theNoneTypewhenallow_none=True.Signed-off-by: Gautam Kumar Giri personal.gautamgiri@gmail.com
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.(run the linters)