22import logging
33from collections import namedtuple
44from enum import Enum
5- from typing import Any , Callable , List , Tuple
5+ from typing import Any , Callable , List , Tuple , cast
66
77from . import export
88
@@ -116,7 +116,7 @@ def register_special_command(
116116
117117
118118@export
119- def execute (cur : Any , sql : str ) -> List [Tuple ]:
119+ def execute (cur : Any , sql : str ) -> List [Tuple [ Any , ...] ]:
120120 """Execute a special command and return the results. If the special command
121121 is not supported a KeyError will be raised.
122122 """
@@ -133,11 +133,14 @@ def execute(cur: Any, sql: str) -> List[Tuple]:
133133 raise CommandNotFound ("Command not found: %s" % command )
134134
135135 if special_cmd .arg_type == NO_QUERY :
136- return special_cmd .handler ()
136+ return cast ( List [ Tuple [ Any , ...]], special_cmd .handler () )
137137 elif special_cmd .arg_type == PARSED_QUERY :
138- return special_cmd .handler (cur = cur , arg = arg , verbose = (verbosity == Verbosity .VERBOSE ))
138+ return cast (
139+ List [Tuple [Any , ...]],
140+ special_cmd .handler (cur = cur , arg = arg , verbose = (verbosity == Verbosity .VERBOSE )),
141+ )
139142 elif special_cmd .arg_type == RAW_QUERY :
140- return special_cmd .handler (cur = cur , query = sql )
143+ return cast ( List [ Tuple [ Any , ...]], special_cmd .handler (cur = cur , query = sql ) )
141144
142145 raise CommandNotFound (f"Command type not found: { command } " )
143146
@@ -181,5 +184,5 @@ def quit(*_args: Any) -> None:
181184 case_sensitive = False ,
182185 aliases = (".ai" , ".llm" ),
183186)
184- def stub ():
187+ def stub () -> None :
185188 raise NotImplementedError
0 commit comments