Add type hints for inspectdb/sqlite

This commit is contained in:
Waket Zheng 2024-06-02 17:56:54 +08:00
parent dd11bed5a0
commit a917f253c9

View File

@ -1,11 +1,11 @@
from typing import List from typing import Callable, Dict, List
from aerich.inspectdb import Column, Inspect from aerich.inspectdb import Column, Inspect
class InspectSQLite(Inspect): class InspectSQLite(Inspect):
@property @property
def field_map(self) -> dict: def field_map(self) -> Dict[str, Callable[..., str]]:
return { return {
"INTEGER": self.int_field, "INTEGER": self.int_field,
"INT": self.bool_field, "INT": self.bool_field,
@ -45,7 +45,7 @@ class InspectSQLite(Inspect):
) )
return columns return columns
async def _get_columns_index(self, table: str): async def _get_columns_index(self, table: str) -> Dict[str, str]:
sql = f"PRAGMA index_list ({table})" sql = f"PRAGMA index_list ({table})"
indexes = await self.conn.execute_query_dict(sql) indexes = await self.conn.execute_query_dict(sql)
ret = {} ret = {}