Skip to content

Commit 4c7f40d

Browse files
authored
Merge pull request #14 from Cloudhabil/codex/debug-lint-and-type-tests
Fix lint/typecheck workflow and mypy errors
2 parents 26d14f6 + 5451251 commit 4c7f40d

5 files changed

Lines changed: 14 additions & 10 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ ui-mindmap:
1616
>cd ui/cli-ia-mindmap && npm install && npm run dev
1717

1818
lint:
19-
>flake8 .
19+
>python -m flake8 .
2020

2121
typecheck:
22-
>mypy bus_server.py kb.py agent_server.py server tests
22+
>python -m mypy src/bus_server.py src/core/kb.py src/agent_server.py src/server
2323

2424
test:
2525
>python -m pytest -q

models/backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def chat(self, messages: List[Dict[str, str]]) -> str:
112112
if role == "system":
113113
system_content = (system_content + "\n" if system_content else "") + content
114114
continue
115-
converted.append({"role": role, "content": [{"type": "text", "text": content}]}
115+
converted.append({"role": role, "content": [{"type": "text", "text": content}]})
116116

117117
headers = {
118118
"x-api-key": self.api_key,
@@ -149,4 +149,4 @@ def make_client(kind: str, endpoint: str, model: str):
149149
if kind == "anthropic":
150150
# Anthropic ignores the OpenAI-style endpoint; pass endpoint if overridden
151151
return AnthropicChat(model=model, endpoint=endpoint or None)
152-
raise ValueError(f"unknown model backend {kind}")
152+
raise ValueError(f"unknown model backend {kind}")

src/agent_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ async def health_check() -> Dict[str, str]:
312312
@app.post("/wake")
313313
async def wake_up() -> Dict[str, str]:
314314
if bus is not None:
315-
bus.subscribe(role, lambda msg: logger.info("[%s] received: %s", role, msg)) # type: ignore[attr-defined]
315+
logger.info("Bus client active for role %s", role)
316316
init_cron()
317317
return {"status": "awake", "role": role}
318318

src/bus_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import logging
1111
import traceback
1212
import re
13-
from typing import Any, Dict
13+
from typing import Any, AsyncIterator, Dict
1414

1515
from fastapi import FastAPI, Depends, HTTPException, Request, status
1616
from contextlib import asynccontextmanager
@@ -25,7 +25,7 @@
2525
from integrations import social_hooks
2626

2727
@asynccontextmanager
28-
async def lifespan(app: FastAPI):
28+
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
2929
try:
3030
yield
3131
finally:

src/server/main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import json
77
import os
88
from pathlib import Path
9-
from typing import Any, Dict
9+
from typing import Any, AsyncIterator, Dict
1010
import logging
1111
import traceback
1212
import redis
@@ -49,7 +49,7 @@
4949

5050

5151
@asynccontextmanager
52-
async def lifespan(app: FastAPI):
52+
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
5353
await init_db()
5454
try:
5555
yield
@@ -81,7 +81,11 @@ async def healthz() -> Dict[str, bool]:
8181
async def readyz() -> Dict[str, bool]:
8282
db_ok = await ping_db()
8383
try:
84-
redis_ok = bool(await get_redis().ping())
84+
ping_result = get_redis().ping()
85+
if asyncio.iscoroutine(ping_result):
86+
redis_ok = bool(await ping_result)
87+
else:
88+
redis_ok = bool(ping_result)
8589
except redis.exceptions.ConnectionError as exc:
8690
logger.error("Redis connection error during readyz: %s", exc)
8791
REDIS_READYZ_FAILURES.labels(reason="connection_error").inc()

0 commit comments

Comments
 (0)