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

Commit c99da2d

Browse files
author
David Robertson
authored
Annotations for user_erasure_store (#11313)
I'm not sure why this was excluded---it seemed to be passing for me. But it's easy enough to fixup.
1 parent 6a605f4 commit c99da2d

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

changelog.d/11313.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add type hints to storage classes.

mypy.ini

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ exclude = (?x)
5353
|synapse/storage/databases/main/stats.py
5454
|synapse/storage/databases/main/transactions.py
5555
|synapse/storage/databases/main/user_directory.py
56-
|synapse/storage/databases/main/user_erasure_store.py
5756
|synapse/storage/schema/
5857

5958
|tests/api/test_auth.py
@@ -184,6 +183,9 @@ disallow_untyped_defs = True
184183
[mypy-synapse.storage.databases.main.room_batch]
185184
disallow_untyped_defs = True
186185

186+
[mypy-synapse.storage.databases.main.user_erasure_store]
187+
disallow_untyped_defs = True
188+
187189
[mypy-synapse.storage.util.*]
188190
disallow_untyped_defs = True
189191

synapse/storage/databases/main/user_erasure_store.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414

1515
from typing import Dict, Iterable
1616

17-
from synapse.storage._base import SQLBaseStore
17+
from synapse.storage.database import LoggingTransaction
18+
from synapse.storage.databases.main import CacheInvalidationWorkerStore
1819
from synapse.util.caches.descriptors import cached, cachedList
1920

2021

21-
class UserErasureWorkerStore(SQLBaseStore):
22+
class UserErasureWorkerStore(CacheInvalidationWorkerStore):
2223
@cached()
2324
async def is_user_erased(self, user_id: str) -> bool:
2425
"""
@@ -69,7 +70,7 @@ async def mark_user_erased(self, user_id: str) -> None:
6970
user_id: full user_id to be erased
7071
"""
7172

72-
def f(txn):
73+
def f(txn: LoggingTransaction) -> None:
7374
# first check if they are already in the list
7475
txn.execute("SELECT 1 FROM erased_users WHERE user_id = ?", (user_id,))
7576
if txn.fetchone():
@@ -89,7 +90,7 @@ async def mark_user_not_erased(self, user_id: str) -> None:
8990
user_id: full user_id to be un-erased
9091
"""
9192

92-
def f(txn):
93+
def f(txn: LoggingTransaction) -> None:
9394
# first check if they are already in the list
9495
txn.execute("SELECT 1 FROM erased_users WHERE user_id = ?", (user_id,))
9596
if not txn.fetchone():

0 commit comments

Comments
 (0)