From 4d8a3c54756952542c3025ccbd089b7fdfd8e486 Mon Sep 17 00:00:00 2001 From: BeiMu-new <2690322907@qq.com> Date: Fri, 9 Oct 2026 10:42:04 +0800 Subject: [PATCH] style(test): hoist the sleeps collector out of the transient-failure loop CI / Python quality failed on d5dc9b2: the pylint hook reported tests/unit/test_local_embedding_store.py:935:16: W0640: Cell variable sleeps defined in loop (cell-var-from-loop) `fake_sleep` closes over `sleeps` while the loop rebinds it on every iteration. The collector is now created once before the loop and cleared at the top of each iteration, which keeps the per-iteration assertion (`assert sleeps == [1.0]`) exactly as strict and removes the loop-scoped rebinding. Verification (repo hook arguments): pylint -> Your code has been rated at 10.00/10, exit 0 black --check --line-length=120 --target-version=py311 -> clean flake8 --extend-ignore=E203 --max-line-length=120 -> clean --- tests/unit/test_local_embedding_store.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/unit/test_local_embedding_store.py b/tests/unit/test_local_embedding_store.py index 880ff8fa..da75be04 100644 --- a/tests/unit/test_local_embedding_store.py +++ b/tests/unit/test_local_embedding_store.py @@ -928,11 +928,13 @@ def test_per_item_fallback_keeps_a_transiently_failed_vector(monkeypatch): ConnectionError("connection reset"), TimeoutError("request timed out"), ) - for transient in transients: - sleeps = [] + sleeps = [] - async def fake_sleep(delay): - sleeps.append(delay) + async def fake_sleep(delay): + sleeps.append(delay) + + for transient in transients: + sleeps.clear() provider = PerItemLimitThenTransientErrorAsEmbedding(transient) store = LocalEmbeddingStore(