diff options
author | reivilibre <38398653+reivilibre@users.noreply.github.com> | 2020-09-04 12:02:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-04 12:02:29 +0100 |
commit | e35129844466ec5f63a744fa2181cd0f8691e49c (patch) | |
tree | 0ca2b3601de652d6dce87b6a96bdba34b1ded8e7 | |
parent | Stop sub-classing object (#8249) (diff) | |
download | synapse-e35129844466ec5f63a744fa2181cd0f8691e49c.tar.xz |
Fix type signature in simple_select_one_onecol and friends (#8241)
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
-rw-r--r-- | changelog.d/8241.misc | 1 | ||||
-rw-r--r-- | synapse/storage/database.py | 17 |
2 files changed, 8 insertions, 10 deletions
diff --git a/changelog.d/8241.misc b/changelog.d/8241.misc new file mode 100644 index 0000000000..cb557122aa --- /dev/null +++ b/changelog.d/8241.misc @@ -0,0 +1 @@ +Add type hints to `synapse.storage.database`. diff --git a/synapse/storage/database.py b/synapse/storage/database.py index 8be943f589..ed8a9bffb1 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -1104,7 +1104,7 @@ class DatabasePool: self, table: str, keyvalues: Dict[str, Any], - retcol: Iterable[str], + retcol: str, allow_none: Literal[False] = False, desc: str = "simple_select_one_onecol", ) -> Any: @@ -1115,7 +1115,7 @@ class DatabasePool: self, table: str, keyvalues: Dict[str, Any], - retcol: Iterable[str], + retcol: str, allow_none: Literal[True] = True, desc: str = "simple_select_one_onecol", ) -> Optional[Any]: @@ -1125,7 +1125,7 @@ class DatabasePool: self, table: str, keyvalues: Dict[str, Any], - retcol: Iterable[str], + retcol: str, allow_none: bool = False, desc: str = "simple_select_one_onecol", ) -> Optional[Any]: @@ -1156,7 +1156,7 @@ class DatabasePool: txn: LoggingTransaction, table: str, keyvalues: Dict[str, Any], - retcol: Iterable[str], + retcol: str, allow_none: Literal[False] = False, ) -> Any: ... @@ -1168,7 +1168,7 @@ class DatabasePool: txn: LoggingTransaction, table: str, keyvalues: Dict[str, Any], - retcol: Iterable[str], + retcol: str, allow_none: Literal[True] = True, ) -> Optional[Any]: ... @@ -1179,7 +1179,7 @@ class DatabasePool: txn: LoggingTransaction, table: str, keyvalues: Dict[str, Any], - retcol: Iterable[str], + retcol: str, allow_none: bool = False, ) -> Optional[Any]: ret = cls.simple_select_onecol_txn( @@ -1196,10 +1196,7 @@ class DatabasePool: @staticmethod def simple_select_onecol_txn( - txn: LoggingTransaction, - table: str, - keyvalues: Dict[str, Any], - retcol: Iterable[str], + txn: LoggingTransaction, table: str, keyvalues: Dict[str, Any], retcol: str, ) -> List[Any]: sql = ("SELECT %(retcol)s FROM %(table)s") % {"retcol": retcol, "table": table} |