Skip to content

Commit

Permalink
Improve type checking in replication.tcp.Stream (matrix-org#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 matrix-org#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 and phil-flex committed Jun 16, 2020
1 parent bb687f7 commit d99998d
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 d99998d

Please sign in to comment.