From 2814aa54a38cc7f5f63dd415c7b0cc8ebe35c623 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Tue, 1 Sep 2026 11:21:19 -0700 Subject: [PATCH] fix(websearch): use the three-arg getattr to satisfy B009 The pure revert restored `getattr(llm_router, "search_tools")`, whose two-argument constant-attribute form ruff flags as B009, and the strict-rule budget has since ratcheted below what that costs Passing an explicit `None` default keeps behavior identical, the preceding `hasattr` guard already proves the attribute is there, while staying inside the budget --- litellm/integrations/websearch_interception/handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/integrations/websearch_interception/handler.py b/litellm/integrations/websearch_interception/handler.py index 81310b9ddc3..3694bf70b48 100644 --- a/litellm/integrations/websearch_interception/handler.py +++ b/litellm/integrations/websearch_interception/handler.py @@ -1633,7 +1633,7 @@ class WebSearchInterceptionLogger(CustomLogger): def _select_search_tool_from_router(self, llm_router: object) -> "_SearchToolConfig | None": if llm_router is None or not hasattr(llm_router, "search_tools"): return None - search_tools: Final = list(getattr(llm_router, "search_tools") or []) + search_tools: Final = list(getattr(llm_router, "search_tools", None) or []) return self._select_search_tool_from_list(search_tools=search_tools, source="router") def _select_search_tool_from_list(