style: apply ruff's automatic fixes and formatter

Mechanical only, and separated from the judgment calls that follow so the
reviewable changes are not buried in a 98-file whitespace diff.

227 automatic fixes: 60 blank lines carrying whitespace, 60 unsorted import
blocks, 34 Optional[X] to X | None, 28 unused imports, 16 deprecated typing
imports, 12 datetime.timezone.utc to datetime.UTC, and assorted smaller
modernisations. Then `ruff format` over src and tests: 98 files reformatted,
35 already conforming.

No file among the unused-import findings defines __all__ or is an __init__.py,
so nothing here removes a re-export.

`make test`: 658 passed, unchanged from HEAD.

Two things observed while verifying, neither addressed here:

`pytest tests/` cannot collect — tests/e2e/test_orchestration_e2e.py uses an
`e2e` marker that is not registered, and the config is strict about markers.
This fails identically at HEAD, so it predates this change; `make test` passes
because it ignores tests/e2e, tests/integration and tests/contracts.

test_tatlock_tool_call_logging_calculator is flaky. It failed once in a full run
with these changes and passed on the next, passes in isolation with them, and
fails in isolation at HEAD. It is order- or timing-dependent, not a regression
from this commit — established by running the full suite both ways rather than
by reasoning about which change could have caused it.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-08-11 17:25:18 +02:00
co-authored by Claude
parent 57fa6c13fc
commit 78066fab1b
103 changed files with 1601 additions and 1749 deletions
+11 -10
View File
@@ -1,6 +1,7 @@
"""
Tests for chat completions router.
"""
import json
import pytest
@@ -17,24 +18,24 @@ def test_chat_completion_non_streaming(
) -> None:
"""Test non-streaming chat completion."""
response = client.post("/v1/chat/completions", json=mock_chat_request)
assert response.status_code == 200
data = response.json()
# Verify response structure
assert "id" in data
assert data["object"] == constants.CHAT_COMPLETION_OBJECT
assert "created" in data
assert data["model"] == mock_chat_request["model"]
assert len(data["choices"]) == 1
# Verify choice structure
choice = data["choices"][0]
assert choice["index"] == 0
assert choice["message"]["role"] == constants.ROLE_ASSISTANT
assert choice["message"]["content"] # Should have content
assert choice["finish_reason"] == constants.FINISH_REASON_STOP
# Verify usage
assert "usage" in data
assert data["usage"]["prompt_tokens"] > 0
@@ -47,9 +48,9 @@ def test_chat_completion_validation_error(client: TestClient) -> None:
"""Test chat completion with invalid request."""
# Missing required field 'messages'
invalid_request = {"model": "Tatlock"}
response = client.post("/v1/chat/completions", json=invalid_request)
assert response.status_code == 422
data = response.json()
assert "error" in data
@@ -108,7 +109,7 @@ async def test_chat_completion_streaming(
# Execute with overall timeout
try:
chunks = await asyncio.wait_for(read_stream_with_timeout(), timeout=20.0)
except asyncio.TimeoutError:
except TimeoutError:
pytest.fail("Streaming test timed out after 20 seconds")
# Verify we got chunks
@@ -133,7 +134,7 @@ def test_chat_completion_temperature_validation(
invalid_request = {**mock_chat_request, "temperature": 3.0}
response = client.post("/v1/chat/completions", json=invalid_request)
assert response.status_code == 422
# Valid temperature
valid_request = {**mock_chat_request, "temperature": 0.5}
response = client.post("/v1/chat/completions", json=valid_request)
@@ -153,7 +154,7 @@ def test_chat_completion_message_roles(
{"role": "user", "content": "Hello!"},
],
}
response = client.post("/v1/chat/completions", json=request_with_system)
assert response.status_code == 200
@@ -168,6 +169,6 @@ def test_chat_completion_invalid_role(
**mock_chat_request,
"messages": [{"role": "invalid_role", "content": "test"}],
}
response = client.post("/v1/chat/completions", json=invalid_request)
assert response.status_code == 422
+15 -27
View File
@@ -7,7 +7,9 @@ Tests that the wrapper correctly:
- Streams reasoning via reasoning_content field (DeepSeek R1 format)
- Streams both reasoning and content
"""
import json
import pytest
from httpx import AsyncClient
@@ -20,10 +22,8 @@ async def test_streaming_wrapper_enables_reasoning(async_client: AsyncClient):
"""Test that streaming wrapper automatically enables reasoning via reasoning_content."""
request_data = {
"model": "lorem-tester",
"messages": [
{"role": "user", "content": "Test message"}
],
"stream": True
"messages": [{"role": "user", "content": "Test message"}],
"stream": True,
}
chunks_received = []
@@ -74,10 +74,8 @@ async def test_streaming_wrapper_reasoning_before_content(async_client: AsyncCli
"""Test that reasoning_content comes before regular content."""
request_data = {
"model": "lorem-tester",
"messages": [
{"role": "user", "content": "Explain something"}
],
"stream": True
"messages": [{"role": "user", "content": "Explain something"}],
"stream": True,
}
chunk_types = [] # Track order: 'reasoning' or 'content'
@@ -127,11 +125,9 @@ async def test_streaming_wrapper_proper_chunk_structure(async_client: AsyncClien
"""Test that streaming chunks have proper structure."""
request_data = {
"model": "lorem-tester",
"messages": [
{"role": "user", "content": "Hello"}
],
"messages": [{"role": "user", "content": "Hello"}],
"temperature": 0.8,
"stream": True
"stream": True,
}
first_chunk = None
@@ -201,9 +197,9 @@ async def test_streaming_wrapper_with_system_message(async_client: AsyncClient):
"model": "lorem-tester",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello"}
{"role": "user", "content": "Hello"},
],
"stream": True
"stream": True,
}
chunks_received = []
@@ -243,10 +239,8 @@ async def test_streaming_wrapper_pipeline_prefix(async_client: AsyncClient):
"""Test streaming with pipeline prefix in model name."""
request_data = {
"model": "some_pipeline.lorem-tester",
"messages": [
{"role": "user", "content": "Test"}
],
"stream": True
"messages": [{"role": "user", "content": "Test"}],
"stream": True,
}
chunks_received = []
@@ -285,17 +279,11 @@ async def test_streaming_wrapper_non_streaming_fallback(async_client: AsyncClien
"""Test that non-streaming request works through wrapper."""
request_data = {
"model": "lorem-tester",
"messages": [
{"role": "user", "content": "Hello"}
],
"stream": False # Non-streaming
"messages": [{"role": "user", "content": "Hello"}],
"stream": False, # Non-streaming
}
response = await async_client.post(
"/v1/chat/completions",
json=request_data,
timeout=20.0
)
response = await async_client.post("/v1/chat/completions", json=request_data, timeout=20.0)
assert response.status_code == 200
data = response.json()