Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(databricks): narrow reasoning_effort_value to str for mypy

mateo-berri2c9166c4f3ec
diff --git a/litellm/llms/databricks/chat/transformation.py b/litellm/llms/databricks/chat/transformation.py
index a0b1ec3d692..34cf174c3fc 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=(