mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-15 17:51:10 +00:00
Overload "allow_none" on DB pool static method
mypy v0.990 fixed overloading static methods on instances
This commit is contained in:
parent
f1a1c7fc53
commit
dacdcf1ba3
1 changed files with 20 additions and 4 deletions
|
@ -2115,10 +2115,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,
|
||||
|
|
Loading…
Reference in a new issue