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

Commit

Permalink
Improve type checking in replication.tcp.Stream (#7291)
Browse files Browse the repository at this point in the history
The general idea here is to get rid of the type: ignore annotations on all of the current_token and update_function assignments, which would have caught #7290.

After a bit of experimentation, it seems like the least-awful way to do this is to pass the offending functions in as parameters to the Stream constructor. Unfortunately that means that the concrete implementations no longer have the same constructor signature as Stream itself, which means that it gets hard to correctly annotate STREAMS_MAP.

I've also introduced a couple of new types, to take out some duplication.
  • Loading branch information
richvdh authored Apr 17, 2020
1 parent c07fca9 commit 67ff7b8
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 122 deletions.
1 change: 1 addition & 0 deletions changelog.d/7291.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve typing annotations in `synapse.replication.tcp.streams.Stream`.
5 changes: 1 addition & 4 deletions synapse/replication/tcp/streams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
update_function: The function that returns a list of updates between two tokens
"""

from typing import Dict, Type

from synapse.replication.tcp.streams._base import (
AccountDataStream,
BackfillStream,
Expand Down Expand Up @@ -67,8 +65,7 @@
GroupServerStream,
UserSignatureStream,
)
} # type: Dict[str, Type[Stream]]

}

__all__ = [
"STREAMS_MAP",
Expand Down
Loading

0 comments on commit 67ff7b8

Please sign in to comment.