From 3407e3cf64699883a2c01b612c7ce798b9cb5b55 Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Wed, 3 Jun 2026 04:20:15 +0200 Subject: [PATCH] chore: run ty on tests/ and make the new ingest tests pass it Stop excluding tests/ from the ty-check pre-commit hook so touched test files are type-checked. Fix the new ingest tests under the now-active check: - cast duck-typed JobContext / App test doubles to their declared types; - narrow the gated Postgres fixture's str | None URL (pytest.skip isn't modelled as NoReturn by ty). Pre-existing type issues in untouched test modules are unaffected (the hook checks only changed files); they'll be cleaned as those files are next touched. Co-Authored-By: Claude Opus 4.8 (1M context) --- .pre-commit-config.yaml | 1 - tests/integration/test_ingest_queue_postgres.py | 2 ++ tests/unit/vector/test_procrastinate_producer.py | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0db3f233..7b559ffc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,5 +22,4 @@ repos: name: ty-check language: system types: [python] - exclude: tests/.* entry: uv run ty check diff --git a/tests/integration/test_ingest_queue_postgres.py b/tests/integration/test_ingest_queue_postgres.py index bc84189c..4b03dd24 100644 --- a/tests/integration/test_ingest_queue_postgres.py +++ b/tests/integration/test_ingest_queue_postgres.py @@ -57,6 +57,8 @@ def postgres_url() -> str: "`docker compose --profile postgres up -d postgres-test` and export " "TEST_DATABASE_URL=postgresql+asyncpg://mcp:mcp@localhost:5433/mcp" ) + # pytest.skip raises, but ty doesn't model it as NoReturn — narrow explicitly. + assert url is not None if not _reachable(url): pytest.skip(f"Postgres at {url} is not reachable") return url diff --git a/tests/unit/vector/test_procrastinate_producer.py b/tests/unit/vector/test_procrastinate_producer.py index d182969a..f84b4b0c 100644 --- a/tests/unit/vector/test_procrastinate_producer.py +++ b/tests/unit/vector/test_procrastinate_producer.py @@ -3,10 +3,11 @@ Uses procrastinate's in-memory connector so no live Postgres is required. """ +from typing import cast from unittest.mock import AsyncMock import pytest -from procrastinate import testing +from procrastinate import App, JobContext, testing import nextcloud_mcp_server.vector.queue.procrastinate as pq from nextcloud_mcp_server.vector.scanner import DocumentTask @@ -158,7 +159,7 @@ class TestReclaimStalledJobs: class Ctx: app = FakeApp() - await pq.reclaim_stalled_ingest_jobs(Ctx(), timestamp=0) + await pq.reclaim_stalled_ingest_jobs(cast(JobContext, Ctx()), timestamp=0) assert retried == [1, 2] @@ -184,7 +185,7 @@ class TestGetIngestJobCounts: class FakeApp: job_manager = FakeManager() - counts = await pq.get_ingest_job_counts(FakeApp()) + counts = await pq.get_ingest_job_counts(cast(App, FakeApp())) assert counts["todo"] == 3 assert counts["doing"] == 1 assert counts["failed"] == 2