From 490390a0578399097f310a820225d93822c5db6d Mon Sep 17 00:00:00 2001 From: "shuwen.wu" Date: Wed, 2 Sep 2026 18:04:17 +0800 Subject: [PATCH] Fix mutable default argument in check_if_part_exists_in_parts Use None as default and initialize empty list inside the function to prevent mutable default argument anti-pattern. --- litellm/llms/vertex_ai/gemini/transformation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/llms/vertex_ai/gemini/transformation.py b/litellm/llms/vertex_ai/gemini/transformation.py index e2d62be6a69..84a70ee3bae 100644 --- a/litellm/llms/vertex_ai/gemini/transformation.py +++ b/litellm/llms/vertex_ai/gemini/transformation.py @@ -613,11 +613,13 @@ def _get_equivalent_key(key: str, available_keys: set) -> str | None: return None -def check_if_part_exists_in_parts(parts: list[PartType], part: PartType, excluded_keys: list[str] = []) -> bool: +def check_if_part_exists_in_parts(parts: list[PartType], part: PartType, excluded_keys: list[str] | None = None) -> bool: """ Check if a part exists in a list of parts Handles both camelCase and snake_case key variations (e.g., function_call vs functionCall) """ + if excluded_keys is None: + excluded_keys = [] keys_to_compare: Final = set(part.keys()) - set(excluded_keys) for p in parts: p_keys = set(p.keys())