element-hq / element-hq/synapse

Improve datastore type hints

Open
#14,678 0 comments 0 reactions 0 assignees View on GitHub
Z-Dev-Wishlist
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#14678](https://github.com/matrix-org/synapse/pull/14678).

---

By being explicit about methods we *should* be able to get better type checking (although this isn't entirely proven in this PR). The idea is to mostly treat datastores the way we handle config classes, each as an individual unit that has to reach back to a "root" object to query other datastores.

This means that the main `DataStore` object would become a bundle of `SQLBaseStore` objects instead of a single entity which has super-classes of `SQLBaseStore`.

As a proof-of-concept I converted the `RelationsStore` (it is simple and I know it fairly well). Other stores could be done in follow-ups.

Related to #11165

Downsides of this approach is it might make #11733 worse as you now have a `DataStore` which includes a `RelationsStore`? It adds another layer to the puzzle.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing RelationsStore proof of concept and how datastore classes are currently structured, then compare that with the config-class approach mentioned in the issue. A concrete follow-up scope, affected stores, validation strategy, and definition of done are not specified here.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, databases
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.