Skip to content

Commit 9eeb7e1

Browse files
committed
LCORE-1569,LCORE-1570: apply black formatting to new files
Whitespace-only reflow produced by `uv run make format` (black with line length 88). Touches the four files added or extended in the preceding 1569/1570 commits — the formatter prefers single-line exception-construction calls and tighter argument layout where the arguments fit under the line limit, which my hand-written layout did not match. No semantic change. Kept as one commit at the tip rather than folded back into each per-ticket commit so the per-ticket diffs remain reviewable on their own without an interleaved cosmetic churn.
1 parent 2ae297f commit 9eeb7e1

4 files changed

Lines changed: 16 additions & 45 deletions

File tree

src/models/config.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,19 +1522,15 @@ class CompactionConfiguration(ConfigurationBase):
15221522
def _validate_threshold_ratio(cls, value: float) -> float:
15231523
"""Reject threshold ratios outside the inclusive 0..1 range."""
15241524
if not 0.0 <= value <= 1.0:
1525-
raise ValueError(
1526-
"threshold_ratio must be between 0.0 and 1.0 (inclusive)"
1527-
)
1525+
raise ValueError("threshold_ratio must be between 0.0 and 1.0 (inclusive)")
15281526
return value
15291527

15301528
@field_validator("buffer_max_ratio")
15311529
@classmethod
15321530
def _validate_buffer_max_ratio(cls, value: float) -> float:
15331531
"""Reject buffer-max ratios outside the inclusive 0..1 range."""
15341532
if not 0.0 <= value <= 1.0:
1535-
raise ValueError(
1536-
"buffer_max_ratio must be between 0.0 and 1.0 (inclusive)"
1537-
)
1533+
raise ValueError("buffer_max_ratio must be between 0.0 and 1.0 (inclusive)")
15381534
return value
15391535

15401536

tests/unit/models/config/test_compaction_configuration.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,13 @@ def test_threshold_ratio_accepts_boundary_values() -> None:
3333

3434
def test_threshold_ratio_rejects_negative() -> None:
3535
"""threshold_ratio below 0 is rejected."""
36-
with pytest.raises(
37-
ValueError, match="threshold_ratio must be between 0.0 and 1.0"
38-
):
36+
with pytest.raises(ValueError, match="threshold_ratio must be between 0.0 and 1.0"):
3937
CompactionConfiguration(threshold_ratio=-0.1)
4038

4139

4240
def test_threshold_ratio_rejects_above_one() -> None:
4341
"""threshold_ratio above 1 is rejected."""
44-
with pytest.raises(
45-
ValueError, match="threshold_ratio must be between 0.0 and 1.0"
46-
):
42+
with pytest.raises(ValueError, match="threshold_ratio must be between 0.0 and 1.0"):
4743
CompactionConfiguration(threshold_ratio=1.1)
4844

4945

tests/unit/utils/test_compaction.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
estimate_conversation_tokens,
2424
)
2525

26-
2726
# ---------------------------------------------------------------------------
2827
# Helpers
2928
# ---------------------------------------------------------------------------
@@ -62,9 +61,7 @@ def _make_history(num_pairs: int, words_per_message: int = 1) -> list[Any]:
6261
snippet = "alpha "
6362
for i in range(num_pairs):
6463
items.append(_MessageItem("user", (snippet * words_per_message) + str(i)))
65-
items.append(
66-
_MessageItem("assistant", (snippet * words_per_message) + f"A{i}")
67-
)
64+
items.append(_MessageItem("assistant", (snippet * words_per_message) + f"A{i}"))
6865
return items
6966

7067

@@ -442,9 +439,7 @@ async def test_invokes_responses_create_with_store_false(
442439
assert "user: hi" in kwargs["input"]
443440

444441
@pytest.mark.asyncio
445-
async def test_raises_when_llm_returns_empty(
446-
self, mocker: MockerFixture
447-
) -> None:
442+
async def test_raises_when_llm_returns_empty(self, mocker: MockerFixture) -> None:
448443
"""An empty LLM response surfaces ValueError, not a silent empty summary."""
449444
client = mocker.AsyncMock()
450445
client.responses.create.return_value = _make_summary_response(mocker, "")
@@ -524,9 +519,7 @@ class TestRecursivelyResummarize:
524519
"""Tests for the recursive-fold fallback."""
525520

526521
@pytest.mark.asyncio
527-
async def test_collapses_n_summaries_into_one(
528-
self, mocker: MockerFixture
529-
) -> None:
522+
async def test_collapses_n_summaries_into_one(self, mocker: MockerFixture) -> None:
530523
"""Multiple summaries fold into one ConversationSummary."""
531524
client = mocker.AsyncMock()
532525
client.responses.create.return_value = _make_summary_response(
@@ -543,20 +536,15 @@ async def test_collapses_n_summaries_into_one(
543536
summaries=summaries,
544537
encoding_name=DEFAULT_ENCODING_NAME,
545538
)
546-
assert (
547-
folded.summary_text
548-
== "Combined summary covering all prior chunks."
549-
)
539+
assert folded.summary_text == "Combined summary covering all prior chunks."
550540
# The fold inherits the most recent input's running total — no
551541
# new turns were summarized by this call.
552542
assert folded.summarized_through_turn == 15
553543
assert folded.token_count > 0
554544
assert folded.model_used == "openai/gpt-4o-mini"
555545

556546
@pytest.mark.asyncio
557-
async def test_prompt_lists_each_summary(
558-
self, mocker: MockerFixture
559-
) -> None:
547+
async def test_prompt_lists_each_summary(self, mocker: MockerFixture) -> None:
560548
"""All input summary texts and the fallback prompt appear in the call."""
561549
client = mocker.AsyncMock()
562550
client.responses.create.return_value = _make_summary_response(
@@ -583,9 +571,7 @@ async def test_prompt_lists_each_summary(
583571
async def test_uses_store_false(self, mocker: MockerFixture) -> None:
584572
"""The recursive call also uses store=False — like the additive one."""
585573
client = mocker.AsyncMock()
586-
client.responses.create.return_value = _make_summary_response(
587-
mocker, "Folded."
588-
)
574+
client.responses.create.return_value = _make_summary_response(mocker, "Folded.")
589575
summaries = [
590576
_make_summary("a", through=1),
591577
_make_summary("b", through=2),
@@ -601,9 +587,7 @@ async def test_uses_store_false(self, mocker: MockerFixture) -> None:
601587
assert kwargs["stream"] is False
602588

603589
@pytest.mark.asyncio
604-
async def test_raises_for_single_summary(
605-
self, mocker: MockerFixture
606-
) -> None:
590+
async def test_raises_for_single_summary(self, mocker: MockerFixture) -> None:
607591
"""Folding a single summary is a no-op the caller must avoid."""
608592
client = mocker.AsyncMock()
609593
with pytest.raises(ValueError, match="at least 2 summary chunks"):
@@ -627,9 +611,7 @@ async def test_raises_for_empty_list(self, mocker: MockerFixture) -> None:
627611
)
628612

629613
@pytest.mark.asyncio
630-
async def test_raises_when_llm_returns_empty(
631-
self, mocker: MockerFixture
632-
) -> None:
614+
async def test_raises_when_llm_returns_empty(self, mocker: MockerFixture) -> None:
633615
"""Empty LLM response surfaces ValueError, not an empty fold."""
634616
client = mocker.AsyncMock()
635617
client.responses.create.return_value = _make_summary_response(mocker, "")

tests/unit/utils/test_token_estimator.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
get_context_window,
1515
)
1616

17-
1817
# ---------------------------------------------------------------------------
1918
# Helpers / fixtures
2019
# ---------------------------------------------------------------------------
@@ -65,9 +64,7 @@ def test_single_word(self) -> None:
6564

6665
def test_pangram(self) -> None:
6766
"""The pangram tokenizes to the known cl100k_base count."""
68-
assert (
69-
estimate_tokens("The quick brown fox jumps over the lazy dog.") == 10
70-
)
67+
assert estimate_tokens("The quick brown fox jumps over the lazy dog.") == 10
7168

7269
def test_known_phrase(self) -> None:
7370
"""A second reference phrase agrees with the published count."""
@@ -214,9 +211,9 @@ def test_accepts_openai_dict_shape(self) -> None:
214211
_MessageItem("user", "hello world"),
215212
_MessageItem("assistant", "hi"),
216213
]
217-
assert estimate_conversation_tokens(
218-
dicts
219-
) == estimate_conversation_tokens(items)
214+
assert estimate_conversation_tokens(dicts) == estimate_conversation_tokens(
215+
items
216+
)
220217

221218
def test_accepts_mixed_shapes(self) -> None:
222219
"""A mixed list of dicts and Llama Stack items is supported."""

0 commit comments

Comments
 (0)