Skip to content

Commit 43d9dfe

Browse files
committed
fix: mypy
1 parent 6ccefac commit 43d9dfe

6 files changed

Lines changed: 23 additions & 15 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ module = [
135135
"googleapiclient.*",
136136
"sentence_transformers",
137137
"numpy",
138+
"openai",
138139
]
139140
ignore_missing_imports = true
140141

src/devscontext/adapters/gmail.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ async def _search_emails(
190190
),
191191
)
192192

193-
return result.get("messages", [])
193+
messages: list[dict[str, Any]] = result.get("messages", [])
194+
return messages
194195

195196
except ImportError:
196197
logger.warning("Gmail dependencies not installed")
@@ -212,7 +213,7 @@ async def _get_message(self, message_id: str) -> dict[str, Any] | None:
212213
service = self._get_service()
213214

214215
loop = asyncio.get_event_loop()
215-
msg = await loop.run_in_executor(
216+
msg: dict[str, Any] = await loop.run_in_executor(
216217
None,
217218
lambda: (
218219
service.users()
@@ -245,7 +246,7 @@ async def _get_thread(self, thread_id: str) -> dict[str, Any] | None:
245246
service = self._get_service()
246247

247248
loop = asyncio.get_event_loop()
248-
thread = await loop.run_in_executor(
249+
thread: dict[str, Any] = await loop.run_in_executor(
249250
None,
250251
lambda: (
251252
service.users()
@@ -411,7 +412,10 @@ async def fetch_task_context(
411412
)
412413

413414
# Group by thread and fetch full threads
414-
thread_ids = list({m.get("threadId") for m in message_refs if m.get("threadId")})
415+
thread_ids: list[str] = [
416+
tid for m in message_refs if (tid := m.get("threadId")) is not None
417+
]
418+
thread_ids = list(dict.fromkeys(thread_ids)) # Deduplicate while preserving order
415419
threads: list[GmailThread] = []
416420

417421
for thread_id in thread_ids[:10]: # Limit threads to avoid too many API calls

src/devscontext/adapters/slack.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ async def _api_call(
216216
response = await client.post(endpoint, json=params)
217217

218218
response.raise_for_status()
219-
data = response.json()
219+
data: dict[str, Any] = response.json()
220220

221221
if not data.get("ok"):
222222
error = data.get("error", "unknown_error")
@@ -331,7 +331,7 @@ async def _search_messages(
331331
)
332332

333333
if data.get("ok"):
334-
matches = data.get("messages", {}).get("matches", [])
334+
matches: list[dict[str, Any]] = data.get("messages", {}).get("matches", [])
335335
if matches:
336336
logger.debug(f"Found {len(matches)} messages via search API")
337337
return matches
@@ -432,7 +432,8 @@ async def _fetch_thread(
432432
if not data.get("ok"):
433433
return []
434434

435-
return data.get("messages", [])
435+
messages: list[dict[str, Any]] = data.get("messages", [])
436+
return messages
436437

437438
def _parse_message(
438439
self,
@@ -626,9 +627,11 @@ async def fetch_task_context(
626627
if thread_msgs:
627628
# Resolve user names for thread participants
628629
for thread_msg in thread_msgs:
629-
user_id = thread_msg.get("user")
630-
if user_id and user_id not in user_names:
631-
user_names[user_id] = await self._resolve_user_name(user_id)
630+
thread_user_id: str | None = thread_msg.get("user")
631+
if thread_user_id and thread_user_id not in user_names:
632+
user_names[thread_user_id] = await self._resolve_user_name(
633+
thread_user_id
634+
)
632635

633636
parent = self._parse_message(
634637
thread_msgs[0], channel_id, channel_name, user_names

src/devscontext/rag/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def is_rag_available() -> bool:
4646
return _RAG_AVAILABLE
4747

4848

49-
def get_embedding_provider(config: RagConfig) -> EmbeddingProvider: # noqa: F821
49+
def get_embedding_provider(config: "RagConfig") -> "EmbeddingProvider": # type: ignore[name-defined]
5050
"""Factory function to create an embedding provider based on config.
5151
5252
Args:

src/devscontext/rag/embeddings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(self, model: str = "all-MiniLM-L6-v2") -> None:
102102
model: Model name from HuggingFace (default: all-MiniLM-L6-v2).
103103
"""
104104
super().__init__(model)
105-
self._model_instance = None
105+
self._model_instance: Any = None
106106

107107
def _load_model(self) -> Any: # Returns SentenceTransformer
108108
"""Lazy-load the sentence-transformers model."""
@@ -237,7 +237,7 @@ def __init__(
237237
"""
238238
super().__init__(model)
239239
self.base_url = os.environ.get("OLLAMA_BASE_URL", base_url)
240-
self._client = None
240+
self._client: Any = None
241241

242242
def _get_client(self) -> Any: # Returns httpx.AsyncClient
243243
"""Lazy-load the HTTP client."""

src/devscontext/rag/index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __init__(self, index_path: str = ".devscontext/doc_index.json") -> None:
8989
self._indexed_at: datetime | None = None
9090
self._sections: list[IndexedSection] = []
9191
self._embeddings: list[list[float]] = []
92-
self._embeddings_array = None # Cached numpy array
92+
self._embeddings_array: Any = None # Cached numpy array
9393

9494
@property
9595
def is_loaded(self) -> bool:
@@ -294,7 +294,7 @@ def get_stats(self) -> dict[str, Any]:
294294
Returns:
295295
Dictionary with index statistics.
296296
"""
297-
doc_types = {}
297+
doc_types: dict[str, int] = {}
298298
for section in self._sections:
299299
doc_types[section.doc_type] = doc_types.get(section.doc_type, 0) + 1
300300

0 commit comments

Comments
 (0)