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

Commit

Permalink
Be explicit about datastores.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Apr 14, 2023
1 parent 8af184a commit 74b88ac
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions synapse/storage/databases/main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ class DataStore(
LockStore,
SessionStore,
):
DATASTORE_CLASSES: List[Type[SQLBaseStore]] = [
RelationsStore,
]

# XXX So mypy knows about dynamic properties.
relations: RelationsStore

def __init__(
self,
database: DatabasePool,
Expand All @@ -147,18 +140,8 @@ def __init__(

super().__init__(database, db_conn, hs)

def repl(match: Match[str]) -> str:
return "_" + match.group(0).lower()

for datastore_class in self.DATASTORE_CLASSES:
name = datastore_class.__name__
if name.endswith("Store"):
name = name[: -len("Store")]

name = re.sub(r"[A-Z]", repl, name)[1:]

store = datastore_class(database, db_conn, hs, self)
setattr(self, name, store)
# This is a bit repetitive, but avoids dynamically setting attributes.
self.relations: RelationsStore = RelationsStore(database, db_conn, hs, self)

async def get_users(self) -> List[JsonDict]:
"""Function to retrieve a list of users in users table.
Expand Down

0 comments on commit 74b88ac

Please sign in to comment.