From affd76499ebb0ed8636b1ec6c3c17aedd96e70ee Mon Sep 17 00:00:00 2001 From: eeshsaxena Date: Mon, 3 Aug 2026 19:47:11 +0530 Subject: [PATCH] refactor: drop inline isinstance guard in type-list normalization JSON Schema type arrays contain only strings, so type_mapping.get(entry, entry) is sufficient and avoids an inline type guard. --- litellm/litellm_core_utils/json_validation_rule.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/litellm/litellm_core_utils/json_validation_rule.py b/litellm/litellm_core_utils/json_validation_rule.py index 861b0b9373a..32cb1eda357 100644 --- a/litellm/litellm_core_utils/json_validation_rule.py +++ b/litellm/litellm_core_utils/json_validation_rule.py @@ -57,9 +57,7 @@ def normalize_json_schema_types( # to mark a field nullable (e.g. ["STRING", "NULL"]). Without this # branch those entries fall through to the generic list recursion, # which leaves the bare strings uppercase. - normalized_schema[key] = [ - type_mapping.get(entry, entry) if isinstance(entry, str) else entry for entry in value - ] + normalized_schema[key] = [type_mapping.get(entry, entry) for entry in value] elif key == "properties" and isinstance(value, dict): # Recursively normalize properties normalized_schema[key] = {