From b6a4384e7bd6471e40a481720cb7a424696c4f01 Mon Sep 17 00:00:00 2001 From: Ambuj Upadhyay <34904987+lets-order-some-fries@users.noreply.github.com> Date: Tue, 27 Oct 2026 07:53:54 +0530 Subject: [PATCH] fix(vertex): keep the basedpyright gate level for the anyOf enum arm The anyOf arm read its branches through schema.get on the unannotated schema dict, so after merging main it added one reportUnknownMemberType, one reportUnknownArgumentType and two reportUnknownVariableType errors, and scripts/type_check_gate.py holds each rule at its merge-base count Test the key and the list type the way the enum check above already does, and read the branches as list[object] with the cast-ok idiom used elsewhere in this file. No behaviour change, the four regression tests still pass --- litellm/llms/vertex_ai/common_utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.py index 025d0b9c6e0..bc1fb36ad87 100644 --- a/litellm/llms/vertex_ai/common_utils.py +++ b/litellm/llms/vertex_ai/common_utils.py @@ -672,9 +672,8 @@ def _fix_enum_empty_strings(schema, depth=0): # An Optional[Literal[...]] arrives here as an `anyOf` branch, because # convert_anyof_null_to_nullable runs first. Without this arm the empty string # survives on optional fields while the same enum is fixed on required ones. - anyof: Final = schema.get("anyOf", None) - if anyof is not None and isinstance(anyof, list): - for item in anyof: + if "anyOf" in schema and isinstance(schema["anyOf"], list): + for item in cast(list[object], schema["anyOf"]): # cast-ok: an untyped JSON list _fix_enum_empty_strings(item, depth=depth + 1)