From 7c5fca06c3efe76f39aba68bda6172668fb6f523 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Wed, 19 Aug 2026 16:30:22 +0200 Subject: [PATCH] chore(types): annotate four containers mypy could not infer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each element type is taken from how the container is used rather than guessed: kept_items is returned from trim_to_fit, whose signature is already list[Any]; traces collects the dicts built at the append site; expert_results and tool_outputs are keyed by tool_name (str) and hold ToolReturnPart.content. tracing_router.py needed `from typing import Any` added — it had no import for it, so annotating without that would have traded a var-annotated error for a name-defined one. Function-body variable annotations are not evaluated at runtime, so this would not have raised; mypy was the only thing that would have caught it. 90 errors -> 86. Co-Authored-By: Claude --- src/agents/tatlock.py | 4 ++-- src/core/tracing_router.py | 3 ++- src/responses/context.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/agents/tatlock.py b/src/agents/tatlock.py index b3331be..bc5ed4c 100644 --- a/src/agents/tatlock.py +++ b/src/agents/tatlock.py @@ -736,8 +736,8 @@ class TatlockAgent(AgentInterface): # Extract tool calls and results from the agent's messages tools_called = [] - expert_results = {} - tool_outputs = {} + expert_results: dict[str, Any] = {} + tool_outputs: dict[str, Any] = {} # Parse through new messages to find tool calls and returns for msg in result.new_messages(): diff --git a/src/core/tracing_router.py b/src/core/tracing_router.py index bffb00a..caf6c22 100644 --- a/src/core/tracing_router.py +++ b/src/core/tracing_router.py @@ -7,6 +7,7 @@ Only available when DEBUG=true. from datetime import UTC from pathlib import Path +from typing import Any from fastapi import APIRouter, HTTPException from fastapi.responses import HTMLResponse, JSONResponse @@ -82,7 +83,7 @@ async def list_traces( reverse=True, ) - traces = [] + traces: list[dict[str, Any]] = [] for path in trace_files: if len(traces) >= limit: break diff --git a/src/responses/context.py b/src/responses/context.py index a255004..cea180a 100644 --- a/src/responses/context.py +++ b/src/responses/context.py @@ -83,7 +83,7 @@ class ContextWindow: return [] # Start from most recent, work backwards - kept_items = [] + kept_items: list[Any] = [] current_tokens = 0 for item in reversed(items):