summary refs log tree commit diff
path: root/synapse/storage/database.py
diff options
context:
space:
mode:
authorAndrew Ferrazzutti <andrewf@element.io>2025-02-10 10:37:05 -0500
committerGitHub <noreply@github.com>2025-02-10 15:37:05 +0000
commite4074749d296ca703c857dedf00c6d0543a0679b (patch)
tree81f54f540d15185077b9a5b358a2dbb5584213b6 /synapse/storage/database.py
parentfeat: Allow multiple values for SSO attribute_requirements via comma separati... (diff)
downloadsynapse-e4074749d296ca703c857dedf00c6d0543a0679b.tar.xz
Overload "allow_none" on DB pool static method (#17616)
### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct
(run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: Quentin Gliech <quenting@element.io>
Diffstat (limited to 'synapse/storage/database.py')
-rw-r--r--synapse/storage/database.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/synapse/storage/database.py b/synapse/storage/database.py

index cb4a5857be..8272e39340 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py
@@ -2159,10 +2159,26 @@ class DatabasePool: if rowcount > 1: raise StoreError(500, "More than one row matched (%s)" % (table,)) - # Ideally we could use the overload decorator here to specify that the - # return type is only optional if allow_none is True, but this does not work - # when you call a static method from an instance. - # See https://github.com/python/mypy/issues/7781 + @overload + @staticmethod + def simple_select_one_txn( + txn: LoggingTransaction, + table: str, + keyvalues: Dict[str, Any], + retcols: Collection[str], + allow_none: Literal[False] = False, + ) -> Tuple[Any, ...]: ... + + @overload + @staticmethod + def simple_select_one_txn( + txn: LoggingTransaction, + table: str, + keyvalues: Dict[str, Any], + retcols: Collection[str], + allow_none: Literal[True] = True, + ) -> Optional[Tuple[Any, ...]]: ... + @staticmethod def simple_select_one_txn( txn: LoggingTransaction,