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

Annotations for user_erasure_store #11313

Merged
merged 2 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/11313.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add type hints to storage classes.
4 changes: 3 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ exclude = (?x)
|synapse/storage/databases/main/stats.py
|synapse/storage/databases/main/transactions.py
|synapse/storage/databases/main/user_directory.py
|synapse/storage/databases/main/user_erasure_store.py
|synapse/storage/schema/

|tests/api/test_auth.py
Expand Down Expand Up @@ -183,6 +182,9 @@ disallow_untyped_defs = True
[mypy-synapse.storage.databases.main.client_ips]
disallow_untyped_defs = True

[mypy-synapse.storage.databases.main.user_erasure_store]
disallow_untyped_defs = True

[mypy-synapse.storage.util.*]
disallow_untyped_defs = True

Expand Down
9 changes: 5 additions & 4 deletions synapse/storage/databases/main/user_erasure_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

from typing import Dict, Iterable

from synapse.storage._base import SQLBaseStore
from synapse.storage.database import LoggingTransaction
from synapse.storage.databases.main import CacheInvalidationWorkerStore
from synapse.util.caches.descriptors import cached, cachedList


class UserErasureWorkerStore(SQLBaseStore):
class UserErasureWorkerStore(CacheInvalidationWorkerStore):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this change, is this due to it calling methods from that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, _invalidate_cache_and_stream is the method in question. Sorry, should have written that down.

@cached()
async def is_user_erased(self, user_id: str) -> bool:
"""
Expand Down Expand Up @@ -69,7 +70,7 @@ async def mark_user_erased(self, user_id: str) -> None:
user_id: full user_id to be erased
"""

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

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