From 8e4c92a8a3d81bf0b604e96f2e05677f003da9f5 Mon Sep 17 00:00:00 2001 From: Julio Quinteros Pro Date: Fri, 20 Feb 2026 13:46:51 -0300 Subject: [PATCH] fix(types): resolve MyPy assignment type errors in logging_utils and vertex transformation logging_utils.py: annotate `copy` as `Union[dict, list]` so the list-branch reassignment is compatible with the dict-branch assignment in the same scope. transformation.py: pre-declare `project_id: Optional[str]` before the if/else block so both branches (str from _ensure_access_token, Optional[str] from vertex_ai_project) are compatible; use `project_id or ""` when passing to get_complete_vertex_url which requires str. Co-Authored-By: Claude Sonnet 4.6 --- litellm/litellm_core_utils/logging_utils.py | 2 +- .../anthropic/experimental_pass_through/transformation.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/litellm/litellm_core_utils/logging_utils.py b/litellm/litellm_core_utils/logging_utils.py index ac7a144762..4b2b740935 100644 --- a/litellm/litellm_core_utils/logging_utils.py +++ b/litellm/litellm_core_utils/logging_utils.py @@ -101,7 +101,7 @@ def _truncate_base64_in_value(value: Any) -> Any: if isinstance(v, str): container[k] = _truncate_base64_in_string(v) elif isinstance(v, dict): - copy = {ck: cv for ck, cv in v.items()} + copy: Union[dict, list] = {ck: cv for ck, cv in v.items()} container[k] = copy stack.append((copy, depth + 1)) elif isinstance(v, list): diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py index d65ae01df0..e05e64988d 100644 --- a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py +++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py @@ -34,6 +34,7 @@ class VertexAIPartnerModelsAnthropicMessagesConfig(AnthropicMessagesConfig, Vert vertex_ai_project = VertexBase.safe_get_vertex_ai_project(litellm_params) vertex_ai_location = VertexBase.safe_get_vertex_ai_location(litellm_params) + project_id: Optional[str] = None if "Authorization" not in headers: vertex_credentials = VertexBase.safe_get_vertex_ai_credentials(litellm_params) @@ -54,7 +55,7 @@ class VertexAIPartnerModelsAnthropicMessagesConfig(AnthropicMessagesConfig, Vert custom_api_base=api_base, vertex_location=vertex_ai_location, vertex_project=vertex_ai_project, - project_id=project_id, + project_id=project_id or "", partner=VertexPartnerProvider.claude, stream=optional_params.get("stream", False), model=model,