From 3065cea562bc8a0ee7379c958a529052c7d89ae7 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Sat, 16 Dec 2023 09:24:26 +0530 Subject: [PATCH] Address mypy typing issues --- src/khoj/database/adapters/__init__.py | 2 +- src/khoj/routers/helpers.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/khoj/database/adapters/__init__.py b/src/khoj/database/adapters/__init__.py index 6e17c15b..31aa1d57 100644 --- a/src/khoj/database/adapters/__init__.py +++ b/src/khoj/database/adapters/__init__.py @@ -401,7 +401,7 @@ class ConversationAdapters: ) max_results = 3 - all_questions = await sync_to_async(list)(all_questions) + all_questions = await sync_to_async(list)(all_questions) # type: ignore if len(all_questions) < max_results: return all_questions diff --git a/src/khoj/routers/helpers.py b/src/khoj/routers/helpers.py index 56fba861..d2a79e39 100644 --- a/src/khoj/routers/helpers.py +++ b/src/khoj/routers/helpers.py @@ -267,7 +267,7 @@ async def text_to_image(message: str) -> Tuple[Optional[str], int]: ) image = response.data[0].b64_json except openai.OpenAIError as e: - logger.error(f"Image Generation failed with {e.http_status}: {e.error}") + logger.error(f"Image Generation failed with {e}", exc_info=True) status_code = 500 return image, status_code @@ -302,7 +302,7 @@ class ApiUserRateLimiter: class ConversationCommandRateLimiter: def __init__(self, trial_rate_limit: int, subscribed_rate_limit: int): - self.cache = defaultdict(lambda: defaultdict(list)) + self.cache: Dict[str, Dict[str, List[float]]] = defaultdict(lambda: defaultdict(list)) self.trial_rate_limit = trial_rate_limit self.subscribed_rate_limit = subscribed_rate_limit self.restricted_commands = [ConversationCommand.Online, ConversationCommand.Image] @@ -351,7 +351,7 @@ class ApiIndexedDataLimiter: if state.billing_enabled is False: return subscribed = has_required_scope(request, ["premium"]) - incoming_data_size_mb = 0 + incoming_data_size_mb = 0.0 deletion_file_names = set() if not request.user.is_authenticated: