From 81b94a5063ad61a7f5a54c0fa5dbd9e613d519c8 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Thu, 3 Sep 2020 15:48:54 +0100 Subject: [PATCH 1/3] Fix type signature in simple_select_one_onecol and friends Signed-off-by: Olivier Wilkinson (reivilibre) --- changelog.d/8241.misc | 1 + synapse/storage/database.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 changelog.d/8241.misc diff --git a/changelog.d/8241.misc b/changelog.d/8241.misc new file mode 100644 index 000000000000..d63111068214 --- /dev/null +++ b/changelog.d/8241.misc @@ -0,0 +1 @@ +Fix type signatures in `simple_select_one_onecol` and friends. diff --git a/synapse/storage/database.py b/synapse/storage/database.py index 78ca6d8346d8..12fc194c94ab 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -1125,7 +1125,7 @@ async def simple_select_one_onecol( 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 @@ def simple_select_one_onecol_txn( txn: LoggingTransaction, table: str, keyvalues: Dict[str, Any], - retcol: Iterable[str], + retcol: str, allow_none: Literal[False] = False, ) -> Any: ... @@ -1179,7 +1179,7 @@ def simple_select_one_onecol_txn( 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( @@ -1199,7 +1199,7 @@ def simple_select_onecol_txn( txn: LoggingTransaction, table: str, keyvalues: Dict[str, Any], - retcol: Iterable[str], + retcol: str, ) -> List[Any]: sql = ("SELECT %(retcol)s FROM %(table)s") % {"retcol": retcol, "table": table} From b6f97e13dfc1bef3477181489c3a64871d72d92c Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Thu, 3 Sep 2020 15:54:43 +0100 Subject: [PATCH 2/3] Sneaky IDE overlords hiding overloads Signed-off-by: Olivier Wilkinson (reivilibre) --- synapse/storage/database.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/synapse/storage/database.py b/synapse/storage/database.py index 12fc194c94ab..39506526d875 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -1104,7 +1104,7 @@ async def simple_select_one_onecol( 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 @@ async def simple_select_one_onecol( 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]: @@ -1168,7 +1168,7 @@ def simple_select_one_onecol_txn( txn: LoggingTransaction, table: str, keyvalues: Dict[str, Any], - retcol: Iterable[str], + retcol: str, allow_none: Literal[True] = True, ) -> Optional[Any]: ... @@ -1196,10 +1196,7 @@ def simple_select_one_onecol_txn( @staticmethod def simple_select_onecol_txn( - txn: LoggingTransaction, - table: str, - keyvalues: Dict[str, Any], - retcol: str, + txn: LoggingTransaction, table: str, keyvalues: Dict[str, Any], retcol: str, ) -> List[Any]: sql = ("SELECT %(retcol)s FROM %(table)s") % {"retcol": retcol, "table": table} From ae46aab58b49d6ff413ff29f48aef23fe3c70a1f Mon Sep 17 00:00:00 2001 From: reivilibre <38398653+reivilibre@users.noreply.github.com> Date: Thu, 3 Sep 2020 15:56:27 +0100 Subject: [PATCH 3/3] Update changelog.d/8241.misc Co-authored-by: Patrick Cloke --- changelog.d/8241.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/8241.misc b/changelog.d/8241.misc index d63111068214..cb557122aaa1 100644 --- a/changelog.d/8241.misc +++ b/changelog.d/8241.misc @@ -1 +1 @@ -Fix type signatures in `simple_select_one_onecol` and friends. +Add type hints to `synapse.storage.database`.