fix: clear the ruff findings that needed a decision

The 21 the automatic pass could not make on its own. `ruff check` and
`ruff format --check` are both clean now; typecheck is still red and is next.

`in_reasoning` in chat/service.py was a complete state machine that nothing read:
initialised False, set True when a reasoning delta arrived, set False when the
summary ended — three assignments, zero reads. Ruff reported one at a time, and
removing each revealed the next, so what looked like a single stray variable took
three passes to bottom out. The branches themselves do real work and are
untouched; only the flag is gone.

Four `raise HTTPException` inside `except` blocks now chain with `from e`. Until
now a failure while handling an error was indistinguishable from the error, which
matters most in exactly the situation where the traceback is all you have.

In biographer/tools.py the binding was unused but the call is not: MemoryType()
is called for the ValueError it raises on an invalid name. The binding is gone
and the call and its comment stay, because dropping the line would have removed
the validation.

The rest are unused bindings in tests where the assertions are on something else
(call_args, mostly), plus three unused loop variables and an isinstance tuple.

One correction to my own work: removing a dead comprehension in
test_error_handling.py left an `if` block with nothing but comments in it, which
is a SyntaxError. Ruff caught it immediately. The block now says what the test
actually pins — that the stream parses without crashing, which reaching that line
demonstrates — rather than computing a list nobody asserts on.

`make test` is intermittent here, and it is not this change.
test_tatlock_tool_call_logging_calculator failed in two of five full runs across
both HEAD and this branch, and passes in the other three; it also fails in
isolation at HEAD while passing in isolation here. Order- or timing-dependent.
Recorded rather than chased, since tests are not gated in this repo yet.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-08-11 17:37:33 +02:00
co-authored by Claude
parent 78066fab1b
commit 5b67f5b66c
12 changed files with 24 additions and 26 deletions
+1 -1
View File
@@ -325,7 +325,7 @@ async def list_memories(
# Convert string to MemoryType
try:
mem_type = MemoryType(memory_type)
MemoryType(memory_type) # validated for its ValueError; the value is unused
except ValueError:
return f"Invalid memory type '{memory_type}'. Use: user_profile, preference, or learned_fact"
+1 -3
View File
@@ -161,7 +161,6 @@ async def create_chat_completion_stream(
# Stream from Responses API
coordinator = StreamingCoordinator()
in_reasoning = False
if use_steward:
stream_generator = coordinator.stream_response_with_steward(response_request)
@@ -172,7 +171,6 @@ async def create_chat_completion_stream(
if event.event == StreamEventType.REASONING_SUMMARY_DELTA:
# Stream reasoning via reasoning_content field (DeepSeek R1 format)
# Open WebUI renders this as collapsible thinking block
in_reasoning = True
yield ChatCompletionChunk(
id=completion_id,
object=constants.CHAT_COMPLETION_CHUNK_OBJECT,
@@ -189,7 +187,7 @@ async def create_chat_completion_stream(
elif event.event == StreamEventType.REASONING_SUMMARY_DONE:
# Signal end of reasoning block (no content needed)
in_reasoning = False
pass # nothing downstream reads this; the event just ends the block
elif event.event == StreamEventType.OUTPUT_TEXT_DELTA:
# Stream message content
+1 -1
View File
@@ -155,4 +155,4 @@ async def get_trace(trace_id: str):
return JSONResponse(content=data)
except Exception as e:
logger.error("trace_read_error", trace_id=trace_id, error=str(e))
raise HTTPException(status_code=500, detail="Failed to read trace")
raise HTTPException(status_code=500, detail="Failed to read trace") from e
+3 -3
View File
@@ -73,12 +73,12 @@ async def create_response(
except ModelNotFoundError as e:
logger.error(f"Model not found: {e}")
raise HTTPException(status_code=404, detail=str(e))
raise HTTPException(status_code=404, detail=str(e)) from e
except AppException as e:
logger.error(f"Application error: {e}")
raise HTTPException(status_code=e.status_code, detail=e.message)
raise HTTPException(status_code=e.status_code, detail=e.message) from e
except Exception as e:
logger.error(f"Unexpected error: {e}", exc_info=True)
raise HTTPException(status_code=500, detail="Internal server error")
raise HTTPException(status_code=500, detail="Internal server error") from e