mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
style: fix ruff format debt in touched files (repo ruff 0.15.3, 120-col)
The lint job's 'Check ruff format' gate flagged: - streaming_iterator.py: 3 line-wraps the branch carried from an 88-column formatting pass (Literal[...] class attr, 2x applied_edits kwargs) that do not fit the repo's 120-column config. - test_handler_thinking_disabled.py: same 88-column wraps on a couple of def lines / patch() calls. Base test file's pre-existing format debt left untouched (it fails the check on base too, so the gate excludes it).
This commit is contained in:
parent
d504c869e6
commit
64d54eff04
2 changed files with 23 additions and 53 deletions
|
|
@ -300,9 +300,7 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper):
|
|||
sent_first_chunk: bool = False
|
||||
sent_content_block_start: bool = False
|
||||
sent_content_block_finish: bool = False
|
||||
current_content_block_type: Literal[
|
||||
"text", "tool_use", "thinking", "redacted_thinking"
|
||||
] = "text"
|
||||
current_content_block_type: Literal["text", "tool_use", "thinking", "redacted_thinking"] = "text"
|
||||
sent_last_message: bool = False
|
||||
holding_chunk: ContentBlockDelta | None = None
|
||||
holding_stop_reason_chunk: MessageBlockDelta | None = None
|
||||
|
|
@ -624,11 +622,7 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper):
|
|||
processed_chunk = LiteLLMAnthropicMessagesAdapter().translate_streaming_openai_response_to_anthropic(
|
||||
response=chunk,
|
||||
current_content_block_index=self.current_content_block_index,
|
||||
applied_edits=(
|
||||
self.applied_edits
|
||||
if is_final_chunk and not will_merge_into_held
|
||||
else None
|
||||
),
|
||||
applied_edits=(self.applied_edits if is_final_chunk and not will_merge_into_held else None),
|
||||
thinking_disabled=self.thinking_disabled,
|
||||
)
|
||||
processed_chunk = self._with_refusal_stop_details(processed_chunk)
|
||||
|
|
@ -890,11 +884,7 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper):
|
|||
processed_chunk = LiteLLMAnthropicMessagesAdapter().translate_streaming_openai_response_to_anthropic(
|
||||
response=chunk,
|
||||
current_content_block_index=self.current_content_block_index,
|
||||
applied_edits=(
|
||||
self.applied_edits
|
||||
if is_final_chunk and not will_merge_into_held
|
||||
else None
|
||||
),
|
||||
applied_edits=(self.applied_edits if is_final_chunk and not will_merge_into_held else None),
|
||||
thinking_disabled=self.thinking_disabled,
|
||||
)
|
||||
processed_chunk = self._with_refusal_stop_details(processed_chunk)
|
||||
|
|
|
|||
|
|
@ -39,9 +39,7 @@ MESSAGES = [{"role": "user", "content": "hello"}]
|
|||
"thinking_param,expected_thinking_disabled",
|
||||
THINKING_PARAMS,
|
||||
)
|
||||
async def test_async_handler_streaming_threads_thinking_disabled(
|
||||
thinking_param, expected_thinking_disabled
|
||||
):
|
||||
async def test_async_handler_streaming_threads_thinking_disabled(thinking_param, expected_thinking_disabled):
|
||||
"""Async handler, stream=True: ``thinking_disabled`` reaches the streaming
|
||||
adapter call."""
|
||||
with (
|
||||
|
|
@ -55,9 +53,7 @@ async def test_async_handler_streaming_threads_thinking_disabled(
|
|||
return_value=({}, {}),
|
||||
),
|
||||
patch("litellm.acompletion", return_value=MagicMock()),
|
||||
patch(
|
||||
"litellm.llms.anthropic.experimental_pass_through.adapters.handler.ANTHROPIC_ADAPTER"
|
||||
) as mock_adapter,
|
||||
patch("litellm.llms.anthropic.experimental_pass_through.adapters.handler.ANTHROPIC_ADAPTER") as mock_adapter,
|
||||
):
|
||||
mock_adapter.translate_completion_output_params_streaming.return_value = iter([])
|
||||
await LiteLLMMessagesToCompletionTransformationHandler.async_anthropic_messages_handler(
|
||||
|
|
@ -67,12 +63,10 @@ async def test_async_handler_streaming_threads_thinking_disabled(
|
|||
stream=True,
|
||||
thinking=thinking_param,
|
||||
)
|
||||
call_kwargs = (
|
||||
mock_adapter.translate_completion_output_params_streaming.call_args.kwargs
|
||||
call_kwargs = mock_adapter.translate_completion_output_params_streaming.call_args.kwargs
|
||||
assert call_kwargs.get("thinking_disabled") is expected_thinking_disabled, (
|
||||
f"thinking={thinking_param!r}: expected thinking_disabled={expected_thinking_disabled}"
|
||||
)
|
||||
assert (
|
||||
call_kwargs.get("thinking_disabled") is expected_thinking_disabled
|
||||
), f"thinking={thinking_param!r}: expected thinking_disabled={expected_thinking_disabled}"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -84,9 +78,7 @@ async def test_async_handler_streaming_threads_thinking_disabled(
|
|||
"thinking_param,expected_thinking_disabled",
|
||||
THINKING_PARAMS,
|
||||
)
|
||||
async def test_async_handler_non_streaming_threads_thinking_disabled(
|
||||
thinking_param, expected_thinking_disabled
|
||||
):
|
||||
async def test_async_handler_non_streaming_threads_thinking_disabled(thinking_param, expected_thinking_disabled):
|
||||
"""Async handler, stream=False: ``thinking_disabled`` reaches the
|
||||
non-streaming adapter call."""
|
||||
with (
|
||||
|
|
@ -100,9 +92,7 @@ async def test_async_handler_non_streaming_threads_thinking_disabled(
|
|||
return_value=({}, {}),
|
||||
),
|
||||
patch("litellm.acompletion", return_value=MagicMock()),
|
||||
patch(
|
||||
"litellm.llms.anthropic.experimental_pass_through.adapters.handler.ANTHROPIC_ADAPTER"
|
||||
) as mock_adapter,
|
||||
patch("litellm.llms.anthropic.experimental_pass_through.adapters.handler.ANTHROPIC_ADAPTER") as mock_adapter,
|
||||
):
|
||||
mock_adapter.translate_completion_output_params.return_value = MagicMock()
|
||||
await LiteLLMMessagesToCompletionTransformationHandler.async_anthropic_messages_handler(
|
||||
|
|
@ -113,9 +103,9 @@ async def test_async_handler_non_streaming_threads_thinking_disabled(
|
|||
thinking=thinking_param,
|
||||
)
|
||||
call_kwargs = mock_adapter.translate_completion_output_params.call_args.kwargs
|
||||
assert (
|
||||
call_kwargs.get("thinking_disabled") is expected_thinking_disabled
|
||||
), f"thinking={thinking_param!r}: expected thinking_disabled={expected_thinking_disabled}"
|
||||
assert call_kwargs.get("thinking_disabled") is expected_thinking_disabled, (
|
||||
f"thinking={thinking_param!r}: expected thinking_disabled={expected_thinking_disabled}"
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -127,9 +117,7 @@ async def test_async_handler_non_streaming_threads_thinking_disabled(
|
|||
"thinking_param,expected_thinking_disabled",
|
||||
THINKING_PARAMS,
|
||||
)
|
||||
def test_sync_handler_streaming_threads_thinking_disabled(
|
||||
thinking_param, expected_thinking_disabled
|
||||
):
|
||||
def test_sync_handler_streaming_threads_thinking_disabled(thinking_param, expected_thinking_disabled):
|
||||
"""Sync handler, stream=True: ``thinking_disabled`` reaches the streaming
|
||||
adapter call.
|
||||
|
||||
|
|
@ -143,9 +131,7 @@ def test_sync_handler_streaming_threads_thinking_disabled(
|
|||
return_value=({}, {}),
|
||||
),
|
||||
patch("litellm.completion", return_value=MagicMock()),
|
||||
patch(
|
||||
"litellm.llms.anthropic.experimental_pass_through.adapters.handler.ANTHROPIC_ADAPTER"
|
||||
) as mock_adapter,
|
||||
patch("litellm.llms.anthropic.experimental_pass_through.adapters.handler.ANTHROPIC_ADAPTER") as mock_adapter,
|
||||
):
|
||||
mock_adapter.translate_completion_output_params_streaming.return_value = iter([])
|
||||
LiteLLMMessagesToCompletionTransformationHandler.anthropic_messages_handler(
|
||||
|
|
@ -155,12 +141,10 @@ def test_sync_handler_streaming_threads_thinking_disabled(
|
|||
stream=True,
|
||||
thinking=thinking_param,
|
||||
)
|
||||
call_kwargs = (
|
||||
mock_adapter.translate_completion_output_params_streaming.call_args.kwargs
|
||||
call_kwargs = mock_adapter.translate_completion_output_params_streaming.call_args.kwargs
|
||||
assert call_kwargs.get("thinking_disabled") is expected_thinking_disabled, (
|
||||
f"thinking={thinking_param!r}: expected thinking_disabled={expected_thinking_disabled}"
|
||||
)
|
||||
assert (
|
||||
call_kwargs.get("thinking_disabled") is expected_thinking_disabled
|
||||
), f"thinking={thinking_param!r}: expected thinking_disabled={expected_thinking_disabled}"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -172,9 +156,7 @@ def test_sync_handler_streaming_threads_thinking_disabled(
|
|||
"thinking_param,expected_thinking_disabled",
|
||||
THINKING_PARAMS,
|
||||
)
|
||||
def test_sync_handler_non_streaming_threads_thinking_disabled(
|
||||
thinking_param, expected_thinking_disabled
|
||||
):
|
||||
def test_sync_handler_non_streaming_threads_thinking_disabled(thinking_param, expected_thinking_disabled):
|
||||
"""Sync handler, stream=False: ``thinking_disabled`` reaches the
|
||||
non-streaming adapter call.
|
||||
|
||||
|
|
@ -188,9 +170,7 @@ def test_sync_handler_non_streaming_threads_thinking_disabled(
|
|||
return_value=({}, {}),
|
||||
),
|
||||
patch("litellm.completion", return_value=MagicMock()),
|
||||
patch(
|
||||
"litellm.llms.anthropic.experimental_pass_through.adapters.handler.ANTHROPIC_ADAPTER"
|
||||
) as mock_adapter,
|
||||
patch("litellm.llms.anthropic.experimental_pass_through.adapters.handler.ANTHROPIC_ADAPTER") as mock_adapter,
|
||||
):
|
||||
mock_adapter.translate_completion_output_params.return_value = MagicMock()
|
||||
LiteLLMMessagesToCompletionTransformationHandler.anthropic_messages_handler(
|
||||
|
|
@ -201,6 +181,6 @@ def test_sync_handler_non_streaming_threads_thinking_disabled(
|
|||
thinking=thinking_param,
|
||||
)
|
||||
call_kwargs = mock_adapter.translate_completion_output_params.call_args.kwargs
|
||||
assert (
|
||||
call_kwargs.get("thinking_disabled") is expected_thinking_disabled
|
||||
), f"thinking={thinking_param!r}: expected thinking_disabled={expected_thinking_disabled}"
|
||||
assert call_kwargs.get("thinking_disabled") is expected_thinking_disabled, (
|
||||
f"thinking={thinking_param!r}: expected thinking_disabled={expected_thinking_disabled}"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue