Fix type signature in simple_select_one_onecol and friends (#8241)

Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
This commit is contained in:
reivilibre 2020-09-04 12:02:29 +01:00 committed by GitHub
parent c619253db8
commit e351298444
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions

1
changelog.d/8241.misc Normal file
View File

@ -0,0 +1 @@
Add type hints to `synapse.storage.database`.

View File

@ -1104,7 +1104,7 @@ class DatabasePool:
self, self,
table: str, table: str,
keyvalues: Dict[str, Any], keyvalues: Dict[str, Any],
retcol: Iterable[str], retcol: str,
allow_none: Literal[False] = False, allow_none: Literal[False] = False,
desc: str = "simple_select_one_onecol", desc: str = "simple_select_one_onecol",
) -> Any: ) -> Any:
@ -1115,7 +1115,7 @@ class DatabasePool:
self, self,
table: str, table: str,
keyvalues: Dict[str, Any], keyvalues: Dict[str, Any],
retcol: Iterable[str], retcol: str,
allow_none: Literal[True] = True, allow_none: Literal[True] = True,
desc: str = "simple_select_one_onecol", desc: str = "simple_select_one_onecol",
) -> Optional[Any]: ) -> Optional[Any]:
@ -1125,7 +1125,7 @@ class DatabasePool:
self, self,
table: str, table: str,
keyvalues: Dict[str, Any], keyvalues: Dict[str, Any],
retcol: Iterable[str], retcol: str,
allow_none: bool = False, allow_none: bool = False,
desc: str = "simple_select_one_onecol", desc: str = "simple_select_one_onecol",
) -> Optional[Any]: ) -> Optional[Any]:
@ -1156,7 +1156,7 @@ class DatabasePool:
txn: LoggingTransaction, txn: LoggingTransaction,
table: str, table: str,
keyvalues: Dict[str, Any], keyvalues: Dict[str, Any],
retcol: Iterable[str], retcol: str,
allow_none: Literal[False] = False, allow_none: Literal[False] = False,
) -> Any: ) -> Any:
... ...
@ -1168,7 +1168,7 @@ class DatabasePool:
txn: LoggingTransaction, txn: LoggingTransaction,
table: str, table: str,
keyvalues: Dict[str, Any], keyvalues: Dict[str, Any],
retcol: Iterable[str], retcol: str,
allow_none: Literal[True] = True, allow_none: Literal[True] = True,
) -> Optional[Any]: ) -> Optional[Any]:
... ...
@ -1179,7 +1179,7 @@ class DatabasePool:
txn: LoggingTransaction, txn: LoggingTransaction,
table: str, table: str,
keyvalues: Dict[str, Any], keyvalues: Dict[str, Any],
retcol: Iterable[str], retcol: str,
allow_none: bool = False, allow_none: bool = False,
) -> Optional[Any]: ) -> Optional[Any]:
ret = cls.simple_select_onecol_txn( ret = cls.simple_select_onecol_txn(
@ -1196,10 +1196,7 @@ class DatabasePool:
@staticmethod @staticmethod
def simple_select_onecol_txn( def simple_select_onecol_txn(
txn: LoggingTransaction, txn: LoggingTransaction, table: str, keyvalues: Dict[str, Any], retcol: str,
table: str,
keyvalues: Dict[str, Any],
retcol: Iterable[str],
) -> List[Any]: ) -> List[Any]:
sql = ("SELECT %(retcol)s FROM %(table)s") % {"retcol": retcol, "table": table} sql = ("SELECT %(retcol)s FROM %(table)s") % {"retcol": retcol, "table": table}