fix: annotate anyOf list construction for the LIT002 budget

This commit is contained in:
Debanshu Das 2026-09-17 22:40:02 +00:00
parent 3bd5b6d60f
commit dd897e571d

View file

@ -854,7 +854,9 @@ def convert_anyof_null_to_nullable(schema, depth=0):
anyof: Final = schema.get("anyOf", None)
if anyof is not None:
contains_null: Final = any(isinstance(atype, dict) and atype.get("type") == "null" for atype in anyof)
remaining: Final = [atype for atype in anyof if not (isinstance(atype, dict) and atype.get("type") == "null")]
remaining: Final = [ # mutable-ok: anyOf must stay a list for downstream schema consumers
atype for atype in anyof if not (isinstance(atype, dict) and atype.get("type") == "null")
]
if len(remaining) == 0:
# Edge case: response schema with only null type present is invalid in Vertex AI