From 7c13c6e49ac74150c7d06ebba647009ee52c2a66 Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Wed, 17 Jun 2026 23:04:26 +0200 Subject: [PATCH] =?UTF-8?q?test(integration):=20address=20round-4=20review?= =?UTF-8?q?=20=E2=80=94=20type=20hints=20&=20small=20robustness?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Type the new helper signatures (CLAUDE.md A5): `mcp_client: Any` in document_is_searchable and `nc_mcp_client: Any` in _top_score. - _top_score: guard the results list directly (`if not results`) instead of via total_found, so max() can't hit an empty sequence. - _get_with_retry: replace `raise last_exc # type: ignore` with an explicit `assert last_exc is not None` then raise — clearer intent, no suppressor. Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/integration/_search_helpers.py | 3 ++- tests/integration/test_astrolabe_session_jwt_search.py | 3 ++- tests/integration/test_rag.py | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/integration/_search_helpers.py b/tests/integration/_search_helpers.py index 65800bed..c40ddb29 100644 --- a/tests/integration/_search_helpers.py +++ b/tests/integration/_search_helpers.py @@ -6,12 +6,13 @@ the single-user sampling tests can import it. import json import logging +from typing import Any logger = logging.getLogger(__name__) async def document_is_searchable( - mcp_client, search_term: str, note_id: int | None = None + mcp_client: Any, search_term: str, note_id: int | None = None ) -> bool: """Return True once a freshly-created document is retrievable. diff --git a/tests/integration/test_astrolabe_session_jwt_search.py b/tests/integration/test_astrolabe_session_jwt_search.py index 583a300a..40141b0e 100644 --- a/tests/integration/test_astrolabe_session_jwt_search.py +++ b/tests/integration/test_astrolabe_session_jwt_search.py @@ -57,7 +57,8 @@ async def _get_with_retry( "GET %s failed (attempt %s/%s): %s", url, attempt, max_attempts, e ) await anyio.sleep(2) - raise last_exc # type: ignore[misc] + assert last_exc is not None # loop ran at least once, so this is set + raise last_exc async def _astrolabe_configured(client: httpx.AsyncClient, auth) -> bool: diff --git a/tests/integration/test_rag.py b/tests/integration/test_rag.py index 41e8956c..ea55a7a5 100644 --- a/tests/integration/test_rag.py +++ b/tests/integration/test_rag.py @@ -405,7 +405,7 @@ async def test_retrieval_quality_all_queries( ) -async def _top_score(nc_mcp_client, query: str) -> float | None: +async def _top_score(nc_mcp_client: Any, query: str) -> float | None: """Return the best fusion score for ``query``, or None if no results.""" result = await nc_mcp_client.call_tool( "nc_semantic_search", @@ -413,9 +413,10 @@ async def _top_score(nc_mcp_client, query: str) -> float | None: ) assert result.isError is False data = json.loads(result.content[0].text) - if data["total_found"] == 0: + results = data.get("results", []) + if not results: # guard the list directly, not via total_found return None - return max(r["score"] for r in data["results"]) + return max(r["score"] for r in results) async def test_no_results_for_unrelated_query(nc_mcp_client, indexed_manual_pdf):