fix type checking

This commit is contained in:
bryan davis 2026-07-08 16:24:40 -05:00
parent 9497921d9c
commit d8ea016119
No known key found for this signature in database
GPG key ID: D11B4A4C0C731E5E

View file

@ -281,7 +281,8 @@ async def test_embed_chunks_non_bytes_picture_not_deduped():
chunks = [] chunks = []
for i in range(2): for i in range(2):
c = Chunk(id=f"pic{i}", content="x", order=i) c = Chunk(id=f"pic{i}", content="x", order=i)
c._picture_data = payload # Deliberately off-type to exercise the non-bytes defensive branch.
c._picture_data = payload # ty: ignore[invalid-assignment]
chunks.append(c) chunks.append(c)
embedder = _ImageStubEmbedder() embedder = _ImageStubEmbedder()
@ -484,7 +485,7 @@ async def test_vllm_reuses_pooled_client(monkeypatch):
instead of opening a fresh connection per call.""" instead of opening a fresh connection per call."""
from haiku.rag.embeddings.vllm import VLLMMultimodalEmbedder from haiku.rag.embeddings.vllm import VLLMMultimodalEmbedder
constructed: list[object] = [] stats = {"constructed": 0, "closed": 0}
class FakeResponse: class FakeResponse:
def raise_for_status(self): def raise_for_status(self):
@ -495,14 +496,13 @@ async def test_vllm_reuses_pooled_client(monkeypatch):
class FakeAsyncClient: class FakeAsyncClient:
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
constructed.append(self) stats["constructed"] += 1
self.closed = False
async def post(self, url, json, headers): async def post(self, url, json, headers):
return FakeResponse() return FakeResponse()
async def aclose(self): async def aclose(self):
self.closed = True stats["closed"] += 1
monkeypatch.setattr("httpx.AsyncClient", FakeAsyncClient) monkeypatch.setattr("httpx.AsyncClient", FakeAsyncClient)
@ -513,9 +513,9 @@ async def test_vllm_reuses_pooled_client(monkeypatch):
await embedder.embed_query("two") await embedder.embed_query("two")
await embedder.embed_documents(["three", "four"]) await embedder.embed_documents(["three", "four"])
assert len(constructed) == 1 # one pooled client, reused assert stats["constructed"] == 1 # one pooled client, reused
await embedder.aclose() await embedder.aclose()
assert constructed[0].closed is True assert stats["closed"] == 1
async def test_vllm_aclose_without_request_is_noop(monkeypatch): async def test_vllm_aclose_without_request_is_noop(monkeypatch):