Skip to content

Commit 1615778

Browse files
committed
Fix mypy.
1 parent 624e6d5 commit 1615778

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

litecli/packages/special/favoritequeries.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import annotations
33

4-
from typing import Any, List, Optional
4+
from typing import Any, List, Optional, cast
55

66

77
class FavoriteQueries(object):
@@ -40,10 +40,12 @@ def __init__(self, config: Any) -> None:
4040
self.config = config
4141

4242
def list(self) -> List[str]:
43-
return self.config.get(self.section_name, [])
43+
section = cast(dict[str, str], self.config.get(self.section_name, {}))
44+
return list(section.keys())
4445

4546
def get(self, name: str) -> Optional[str]:
46-
return self.config.get(self.section_name, {}).get(name, None)
47+
section = cast(dict[str, str], self.config.get(self.section_name, {}))
48+
return section.get(name)
4749

4850
def save(self, name: str, query: str) -> None:
4951
if self.section_name not in self.config:

litecli/packages/special/main.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
from collections import namedtuple
44
from enum import Enum
5-
from typing import Any, Callable, List, Tuple
5+
from typing import Any, Callable, List, Tuple, cast
66

77
from . 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

Comments
 (0)