From a48db2e7d7f339059a353fab04354dc1c4ec0a0e Mon Sep 17 00:00:00 2001 From: pokepoke81 <4258646+pokepoke81@users.noreply.github.com> Date: Fri, 21 Aug 2026 14:50:51 -0400 Subject: [PATCH] fix(databricks): read the thinking signature with get to satisfy the type checker thinking_blocks is a union that includes ChatCompletionRedactedThinkingBlock, which has no signature key, so subscripting it tripped reportGeneralTypeIssues and breached the basedpyright budget. The filter already guarantees the key is present. --- litellm/llms/databricks/chat/transformation.py | 2 +- .../llms/databricks/chat/test_databricks_chat_transformation.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/llms/databricks/chat/transformation.py b/litellm/llms/databricks/chat/transformation.py index 9848bb1da31..7e61b231764 100644 --- a/litellm/llms/databricks/chat/transformation.py +++ b/litellm/llms/databricks/chat/transformation.py @@ -502,7 +502,7 @@ class DatabricksConfig(DatabricksBase, OpenAILikeChatConfig, AnthropicConfig): holds_reasoning: Final = any(isinstance(b, dict) and b.get("type") == "reasoning" for b in existing) replace: Final = signed is not None and not holds_reasoning and bool(existing) text: Final = (signed.get("thinking") or "") if signed is not None else "" - signature: Final = signed["signature"] if signed is not None else "" + signature: Final = (signed.get("signature") or "") if signed is not None else "" entry: Final = {"type": "summary_text", "text": text, "signature": signature} # mutable-ok: provider JSON block: Final = {"type": "reasoning", "summary": [entry]} # mutable-ok: outbound provider JSON rebuilt: Final = {**stripped, "content": [block, *existing]} # mutable-ok: outbound provider JSON diff --git a/tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py b/tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py index 5a5a8acc748..14de0127d9a 100644 --- a/tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py +++ b/tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py @@ -496,6 +496,8 @@ def test_chunk_parser_without_usage_still_parses_content(): assert result.id == "chatcmpl-test" assert result.model == "databricks-claude-sonnet-5" assert result.choices[0]["delta"]["content"] == "hi" + + def _thinking_message(thinking_blocks, content="391"): return {"role": "assistant", "content": content, "thinking_blocks": thinking_blocks}