From 0f1d41a88cdddc953faac373505f184c8ee23293 Mon Sep 17 00:00:00 2001 From: obafemiferanmi1999 Date: Fri, 8 May 2026 14:25:02 +0100 Subject: [PATCH] fix(transports): use PEP 604 annotation for ToolCall.extra_content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ToolCall.extra_content` was annotated `Optional[Dict[str, Any]]`, but neither `Optional` nor `Dict` are imported at the top of `agent/transports/types.py` — only `Any` is. The rest of the file consistently uses PEP 604 / 585 syntax (e.g. `str | None`, `dict[str, Any] | None`). The file has `from __future__ import annotations`, so the missing names don't crash class definition. But the annotation IS evaluated when anything calls `typing.get_type_hints(ToolCall)` — introspection raises `NameError: name 'Optional' is not defined`. ruff catches it cleanly: F821 Undefined name `Optional` agent/transports/types.py:65:32 F821 Undefined name `Dict` agent/transports/types.py:65:41 Switch the annotation to `dict[str, Any] | None` to match the rest of the file's style. No new imports needed. Verified: - ruff F-checks now pass on the file - `typing.get_type_hints(ToolCall)` succeeds where it raised before - 166/166 tests in tests/agent/transports/ pass on Windows + Python 3.12 --- agent/transports/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/transports/types.py b/agent/transports/types.py index f0da1eb6f89..2deb157535b 100644 --- a/agent/transports/types.py +++ b/agent/transports/types.py @@ -62,7 +62,7 @@ class ToolCall: return (self.provider_data or {}).get("response_item_id") @property - def extra_content(self) -> Optional[Dict[str, Any]]: + def extra_content(self) -> dict[str, Any] | None: """Gemini extra_content (thought_signature) from provider_data. Gemini 3 thinking models attach ``extra_content`` with a