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

Commit 5f0c66f

Browse files
author
David Robertson
committed
Drive-by: annotate all defs
1 parent fa5c919 commit 5f0c66f

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

mypy.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ disallow_untyped_defs = True
117117
[mypy-tests.state.test_profile]
118118
disallow_untyped_defs = True
119119

120+
[mypy-tests.storage.test_id_generators]
121+
disallow_untyped_defs = True
122+
120123
[mypy-tests.storage.test_profile]
121124
disallow_untyped_defs = True
122125

tests/storage/test_id_generators.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
LoggingTransaction,
2323
)
2424
from synapse.storage.engines import IncorrectDatabaseSetup
25+
from synapse.storage.types import Cursor
2526
from synapse.storage.util.id_generators import MultiWriterIdGenerator, StreamIdGenerator
2627
from synapse.util import Clock
2728

@@ -189,9 +190,9 @@ def _setup_db(self, txn: LoggingTransaction) -> None:
189190
)
190191

191192
def _create_id_generator(
192-
self, instance_name="master", writers: Optional[List[str]] = None
193+
self, instance_name: str = "master", writers: Optional[List[str]] = None
193194
) -> MultiWriterIdGenerator:
194-
def _create(conn):
195+
def _create(conn: LoggingDatabaseConnection) -> MultiWriterIdGenerator:
195196
return MultiWriterIdGenerator(
196197
conn,
197198
self.db_pool,
@@ -587,7 +588,7 @@ def test_sequence_consistency(self) -> None:
587588
self._insert_row_with_id("master", 3)
588589

589590
# Now we add a row *without* updating the stream ID
590-
def _insert(txn):
591+
def _insert(txn: Cursor) -> None:
591592
txn.execute("INSERT INTO foobar VALUES (26, 'master')")
592593

593594
self.get_success(self.db_pool.runInteraction("_insert", _insert))
@@ -622,9 +623,9 @@ def _setup_db(self, txn: LoggingTransaction) -> None:
622623
)
623624

624625
def _create_id_generator(
625-
self, instance_name="master", writers: Optional[List[str]] = None
626+
self, instance_name: str = "master", writers: Optional[List[str]] = None
626627
) -> MultiWriterIdGenerator:
627-
def _create(conn):
628+
def _create(conn: LoggingDatabaseConnection) -> MultiWriterIdGenerator:
628629
return MultiWriterIdGenerator(
629630
conn,
630631
self.db_pool,
@@ -758,9 +759,9 @@ def _setup_db(self, txn: LoggingTransaction) -> None:
758759
)
759760

760761
def _create_id_generator(
761-
self, instance_name="master", writers: Optional[List[str]] = None
762+
self, instance_name: str = "master", writers: Optional[List[str]] = None
762763
) -> MultiWriterIdGenerator:
763-
def _create(conn):
764+
def _create(conn: LoggingDatabaseConnection) -> MultiWriterIdGenerator:
764765
return MultiWriterIdGenerator(
765766
conn,
766767
self.db_pool,
@@ -782,7 +783,7 @@ def _insert_rows(
782783
instance_name: str,
783784
number: int,
784785
update_stream_table: bool = True,
785-
):
786+
) -> None:
786787
"""Insert N rows as the given instance, inserting with stream IDs pulled
787788
from the postgres sequence.
788789
"""

0 commit comments

Comments
 (0)