From b3934b95807a7abd8e8faa99adce13ed647ab0e9 Mon Sep 17 00:00:00 2001 From: Arun Prasad Date: Mon, 27 Oct 2025 15:13:54 +0000 Subject: [PATCH] refactor(anthropic): remove unnecessary url check (#33671) if "url" in annotation: in Line 15 , already ensures "url" is key in annotation , so no need to check again to set "url" key in out object --------- Co-authored-by: Mason Daugherty --- libs/partners/anthropic/langchain_anthropic/_compat.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/partners/anthropic/langchain_anthropic/_compat.py b/libs/partners/anthropic/langchain_anthropic/_compat.py index c86ceef3dc0..d16f5c77274 100644 --- a/libs/partners/anthropic/langchain_anthropic/_compat.py +++ b/libs/partners/anthropic/langchain_anthropic/_compat.py @@ -22,8 +22,7 @@ def _convert_annotation_from_v1(annotation: types.Annotation) -> dict[str, Any]: if "title" in annotation: out["title"] = annotation["title"] out["type"] = "web_search_result_location" - if "url" in annotation: - out["url"] = annotation["url"] + out["url"] = annotation.get("url") for key, value in annotation.get("extras", {}).items(): if key not in out: