From 05c8637ce6bfbc672db57048e7c073e4a59dac0c Mon Sep 17 00:00:00 2001 From: Delweng Date: Tue, 13 Oct 2026 15:46:28 +0800 Subject: [PATCH] fix(token_counter): return a constant for an array param with no items The previous commit reached the missing items case by recursing on an empty dict. That dict has no type key, so _format_type falls through to its else branch and returns the literal any, which makes the recursive call indistinguishable from the constant while handing an untyped empty dict to an unannotated parameter basedpyright counts that call as reportUnknownArgumentType, and scripts/type_check_gate.py fails any rule whose codebase-wide total grows past its merge-base count, with only reportAny and reportExplicitAny exempt. The codebase-wide total for this file now sits one below the merge-base count at 9621a60d27 instead of matching it, and the self-recursion is gone Signed-off-by: Delweng --- litellm/litellm_core_utils/token_counter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/token_counter.py b/litellm/litellm_core_utils/token_counter.py index 31b4a81160f..8b8ea2a5ad3 100644 --- a/litellm/litellm_core_utils/token_counter.py +++ b/litellm/litellm_core_utils/token_counter.py @@ -1180,7 +1180,7 @@ def _format_type(props, indent): return "string" elif type == "array": if "items" not in props: - return f"{_format_type({}, indent)}[]" + return "any[]" return f"{_format_type(props['items'], indent)}[]" elif type == "object": return f"{{\n{_format_object_parameters(props, indent + 2)}\n}}"