From 86e7bcaf54d1d9df38793788bba9388df9a237aa Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Wed, 19 Aug 2026 02:00:51 +0000 Subject: [PATCH] fix(websearch): keep _inject_native_blocks untyped rather than dodge the write Threading a TypeVar through the helper makes the fallback attribute write unprovable, and routing it through setattr to quiet that only trades one diagnostic for a bugbear violation. Leave the seam as it was --- litellm/integrations/websearch_interception/handler.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/litellm/integrations/websearch_interception/handler.py b/litellm/integrations/websearch_interception/handler.py index f6b40836c3a..e59ef0449d0 100644 --- a/litellm/integrations/websearch_interception/handler.py +++ b/litellm/integrations/websearch_interception/handler.py @@ -10,7 +10,7 @@ import asyncio import math import uuid from collections.abc import AsyncIterator, Mapping, Sequence -from typing import TYPE_CHECKING, Any, Final, TypedDict, TypeVar, cast +from typing import TYPE_CHECKING, Any, Final, TypedDict, cast from typing_extensions import ReadOnly @@ -106,9 +106,6 @@ class _UserAuthView(TypedDict): team_id: ReadOnly[str | None] -_ResponseT: Final = TypeVar("_ResponseT") - - class WebSearchInterceptionLogger(CustomLogger): """ CustomLogger that intercepts WebSearch tool calls for models that don't @@ -929,7 +926,7 @@ class WebSearchInterceptionLogger(CustomLogger): ) @staticmethod - def _inject_native_blocks(response: _ResponseT, native_blocks: Sequence[Mapping[str, object]]) -> _ResponseT: + def _inject_native_blocks(response: Any, native_blocks: Sequence[Mapping[str, object]]) -> Any: """Prepend native blocks to response content, dict or object form.""" if not native_blocks: return response @@ -939,7 +936,7 @@ class WebSearchInterceptionLogger(CustomLogger): return response existing = getattr(response, "content", None) or [] try: - setattr(response, "content", list(native_blocks) + list(existing)) + response.content = list(native_blocks) + list(existing) except (AttributeError, TypeError): # Object refused write — fall through and leave the response # untouched rather than crash the request.