ollama[patch]: ruff fixes and rules (#31924)

* bump ruff deps
* add more thorough ruff rules
* fix said rules
This commit is contained in:
Mason Daugherty
2025-07-08 13:42:19 -04:00
committed by GitHub
parent 4d9eefecab
commit 1f829aacf4
11 changed files with 179 additions and 108 deletions

View File

@@ -1,5 +1,7 @@
"""Ollama specific chat model integration tests"""
from __future__ import annotations
from typing import Annotated, Optional
import pytest

View File

@@ -21,8 +21,7 @@ def get_current_weather(location: str) -> dict:
"""Gets the current weather in a given location."""
if "boston" in location.lower():
return {"temperature": "15°F", "conditions": "snow"}
else:
return {"temperature": "unknown", "conditions": "unknown"}
return {"temperature": "unknown", "conditions": "unknown"}
class TestChatOllama(ChatModelIntegrationTests):
@@ -65,16 +64,15 @@ class TestChatOllama(ChatModelIntegrationTests):
if chunk.tool_call_chunks:
tool_chunk_found = True
for tc_chunk in chunk.tool_call_chunks:
collected_tool_chunks.append(tc_chunk)
collected_tool_chunks.extend(chunk.tool_call_chunks)
if chunk.tool_calls:
final_tool_calls.extend(chunk.tool_calls)
assert tool_chunk_found, "Tool streaming did not produce any tool_call_chunks."
assert (
len(final_tool_calls) == 1
), f"Expected 1 final tool call, but got {len(final_tool_calls)}"
assert len(final_tool_calls) == 1, (
f"Expected 1 final tool call, but got {len(final_tool_calls)}"
)
final_tool_call = final_tool_calls[0]
assert final_tool_call["name"] == "get_current_weather"
@@ -110,16 +108,15 @@ class TestChatOllama(ChatModelIntegrationTests):
if chunk.tool_call_chunks:
tool_chunk_found = True
for tc_chunk in chunk.tool_call_chunks:
collected_tool_chunks.append(tc_chunk)
collected_tool_chunks.extend(chunk.tool_call_chunks)
if chunk.tool_calls:
final_tool_calls.extend(chunk.tool_calls)
assert tool_chunk_found, "Tool streaming did not produce any tool_call_chunks."
assert (
len(final_tool_calls) == 1
), f"Expected 1 final tool call, but got {len(final_tool_calls)}"
assert len(final_tool_calls) == 1, (
f"Expected 1 final tool call, but got {len(final_tool_calls)}"
)
final_tool_call = final_tool_calls[0]
assert final_tool_call["name"] == "get_current_weather"

View File

@@ -4,4 +4,3 @@ import pytest
@pytest.mark.compile
def test_placeholder() -> None:
"""Used for compiling integration tests without running any real tests."""
pass