Skip to content

Commit d99998d

Browse files
richvdhphil-flex
authored andcommitted
Improve type checking in replication.tcp.Stream (matrix-org#7291)
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.
1 parent bb687f7 commit d99998d

5 files changed

Lines changed: 143 additions & 122 deletions

File tree

changelog.d/7291.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve typing annotations in `synapse.replication.tcp.streams.Stream`.

synapse/replication/tcp/streams/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
update_function: The function that returns a list of updates between two tokens
2626
"""
2727

28-
from typing import Dict, Type
29-
3028
from synapse.replication.tcp.streams._base import (
3129
AccountDataStream,
3230
BackfillStream,
@@ -67,8 +65,7 @@
6765
GroupServerStream,
6866
UserSignatureStream,
6967
)
70-
} # type: Dict[str, Type[Stream]]
71-
68+
}
7269

7370
__all__ = [
7471
"STREAMS_MAP",

0 commit comments

Comments
 (0)