From 2c9166c4f3ecc807432d0bcb544900e56ddd22e2 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Mon, 4 May 2026 00:52:09 -0700 Subject: [PATCH] fix(databricks): narrow reasoning_effort_value to str for mypy `non_default_params.get("reasoning_effort")` returns `Any | None`, but `REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT.get()` expects `str`. Mypy flagged this on the strict pass. Narrow with `isinstance` before the lookup; non-strings fall through to the existing `BadRequestError` below with a clean validation message, so behavior is unchanged. Fixes a regression introduced by 1a10746e95 in this PR. --- litellm/llms/databricks/chat/transformation.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/litellm/llms/databricks/chat/transformation.py b/litellm/llms/databricks/chat/transformation.py index a0b1ec3d69..34cf174c3f 100644 --- a/litellm/llms/databricks/chat/transformation.py +++ b/litellm/llms/databricks/chat/transformation.py @@ -359,9 +359,15 @@ class DatabricksConfig(DatabricksBase, OpenAILikeChatConfig, AnthropicConfig): if AnthropicConfig._is_claude_4_6_model( model ) or AnthropicConfig._is_claude_4_7_model(model): - mapped_effort = REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT.get( - reasoning_effort_value - ) + # ``reasoning_effort_value`` comes from ``non_default_params`` + # so its static type is ``Any | None``. Narrow to ``str`` for + # the mapping lookup; non-strings fall through to the + # ``BadRequestError`` below with a clean validation message. + mapped_effort: Optional[str] = None + if isinstance(reasoning_effort_value, str): + mapped_effort = REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT.get( + reasoning_effort_value + ) if mapped_effort is None: raise litellm.exceptions.BadRequestError( message=(