mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
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
This commit is contained in:
parent
7602c5ea72
commit
86e7bcaf54
1 changed files with 3 additions and 6 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue