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

Commit 51a5da7

Browse files
David Robertsonsquahtx
andauthored
Annotate synapse.storage.util (#10892)
Also mark `synapse.streams` as having has no untyped defs Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
1 parent 797ee78 commit 51a5da7

File tree

8 files changed

+124
-65
lines changed

8 files changed

+124
-65
lines changed

changelog.d/10892.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add further type hints to `synapse.storage.util`.

mypy.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ disallow_untyped_defs = True
105105
[mypy-synapse.state.*]
106106
disallow_untyped_defs = True
107107

108+
[mypy-synapse.storage.util.*]
109+
disallow_untyped_defs = True
110+
111+
[mypy-synapse.streams.*]
112+
disallow_untyped_defs = True
113+
108114
[mypy-synapse.util.batching_queue]
109115
disallow_untyped_defs = True
110116

synapse/replication/slave/storage/_slaved_id_tracker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
# limitations under the License.
1414
from typing import List, Optional, Tuple
1515

16-
from synapse.storage.types import Connection
16+
from synapse.storage.database import LoggingDatabaseConnection
1717
from synapse.storage.util.id_generators import _load_current_id
1818

1919

2020
class SlavedIdTracker:
2121
def __init__(
2222
self,
23-
db_conn: Connection,
23+
db_conn: LoggingDatabaseConnection,
2424
table: str,
2525
column: str,
2626
extra_tables: Optional[List[Tuple[str, str]]] = None,

synapse/replication/slave/storage/pushers.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
from typing import TYPE_CHECKING
1616

1717
from synapse.replication.tcp.streams import PushersStream
18-
from synapse.storage.database import DatabasePool
18+
from synapse.storage.database import DatabasePool, LoggingDatabaseConnection
1919
from synapse.storage.databases.main.pusher import PusherWorkerStore
20-
from synapse.storage.types import Connection
2120

2221
from ._base import BaseSlavedStore
2322
from ._slaved_id_tracker import SlavedIdTracker
@@ -27,7 +26,12 @@
2726

2827

2928
class SlavedPusherStore(PusherWorkerStore, BaseSlavedStore):
30-
def __init__(self, database: DatabasePool, db_conn: Connection, hs: "HomeServer"):
29+
def __init__(
30+
self,
31+
database: DatabasePool,
32+
db_conn: LoggingDatabaseConnection,
33+
hs: "HomeServer",
34+
):
3135
super().__init__(database, db_conn, hs)
3236
self._pushers_id_gen = SlavedIdTracker( # type: ignore
3337
db_conn, "pushers", "id", extra_tables=[("deleted_pushers", "stream_id")]

synapse/storage/databases/main/pusher.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818

1919
from synapse.push import PusherConfig, ThrottleParams
2020
from synapse.storage._base import SQLBaseStore, db_to_json
21-
from synapse.storage.database import DatabasePool
22-
from synapse.storage.types import Connection
21+
from synapse.storage.database import DatabasePool, LoggingDatabaseConnection
2322
from synapse.storage.util.id_generators import StreamIdGenerator
2423
from synapse.types import JsonDict
2524
from synapse.util import json_encoder
@@ -32,7 +31,12 @@
3231

3332

3433
class PusherWorkerStore(SQLBaseStore):
35-
def __init__(self, database: DatabasePool, db_conn: Connection, hs: "HomeServer"):
34+
def __init__(
35+
self,
36+
database: DatabasePool,
37+
db_conn: LoggingDatabaseConnection,
38+
hs: "HomeServer",
39+
):
3640
super().__init__(database, db_conn, hs)
3741
self._pushers_id_gen = StreamIdGenerator(
3842
db_conn, "pushers", "id", extra_tables=[("deleted_pushers", "stream_id")]

synapse/storage/databases/main/registration.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from synapse.storage.database import DatabasePool, LoggingDatabaseConnection
2727
from synapse.storage.databases.main.cache import CacheInvalidationWorkerStore
2828
from synapse.storage.databases.main.stats import StatsStore
29-
from synapse.storage.types import Connection, Cursor
29+
from synapse.storage.types import Cursor
3030
from synapse.storage.util.id_generators import IdGenerator
3131
from synapse.storage.util.sequence import build_sequence_generator
3232
from synapse.types import UserID, UserInfo
@@ -1775,7 +1775,12 @@ async def is_guest(self, user_id: str) -> bool:
17751775

17761776

17771777
class RegistrationStore(StatsStore, RegistrationBackgroundUpdateStore):
1778-
def __init__(self, database: DatabasePool, db_conn: Connection, hs: "HomeServer"):
1778+
def __init__(
1779+
self,
1780+
database: DatabasePool,
1781+
db_conn: LoggingDatabaseConnection,
1782+
hs: "HomeServer",
1783+
):
17791784
super().__init__(database, db_conn, hs)
17801785

17811786
self._ignore_unknown_session_error = (

0 commit comments

Comments
 (0)