fix(ci): heal mypy tech-debt — unblock 10 Dependabot PRs (closes #60 P2)#62
Merged
Conversation
P2a) qdrant-client >=1.13 removed the `search()` method. Production code raised `AttributeError: 'QdrantClient' has no attribute 'search'`; tests masked the bug via MagicMock. - src/nss/knowledge/vector_store.py: call query_points() and iterate the QueryResponse.points list. - tests/test_knowledge/test_vector_store.py: mock query_points returning a response object with a .points attribute. Verified locally: 209/209 pytest tests pass with qdrant-client 1.18.0, no behavior change in the search contract (id/score/payload dict shape). Refs: nss#60 (mypy attr-defined on vector_store.py:90) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Heal `mypy --ignore-missing-imports` on main (red since W46). Per-file fixes: - src/nss/middleware.py — type `call_next: RequestResponseEndpoint` and `app: ASGIApp` (starlette types); removes 4× `no-any-return` from `await call_next()` and the `Any` ASGI app param. - src/nss/knowledge/sag_encryption.py — type-annotate decoded payload. - src/nss/knowledge/rag_pipeline.py — annotate `results` so the return type matches `list[dict[str, Any]]`. - src/nss/knowledge/embeddings.py — replace 2× now-stale `type: ignore[union-attr]` with explicit `list[float]`/`list[list[float]]` intermediates (no-any-return). - src/nss/cache.py — handle redis-py 7.4 `Awaitable[bool] | bool` return of `ping()` without awaiting a bool literal. - src/nss/auth.py — return-type for `require_role` factory: `Callable[..., Awaitable[dict[str, Any]]]`. - src/nss/guardian/sentinel.py — `float(...)` cast on cosine result. - src/nss/guardian/server.py — `lifespan(app) -> AsyncIterator[None]`. - src/nss/metrics_server.py — return type on `metrics()` / `metrics_prometheus()`, hoist `PlainTextResponse` import, and widen `kwargs: dict[str, Any]` for uvicorn.run (uvicorn's **kwargs is heterogeneous; `dict[str, str]` produced 11 false-positive arg-type errors against the uvicorn stubs). - src/nss/gateway/server.py — `list[Any]` for `_fire_dpia.entities`. Verified locally (Python 3.12, pytest 9.0.3 + all 10 Dependabot dep-bumps installed simultaneously): mypy = 0 errors, ruff = clean, 209/209 tests pass. Unblocks Dependabot PRs #50-#59. Refs: nss#60 (27 mypy errors). qdrant migration carved out into prior commit so this change is pure annotation work with no runtime delta. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Heals the 27
mypy --ignore-missing-importserrors onmainthat block every open Dependabot PR (#50–#59). The Dockerfile (P1) and ruff 0.15 noise (P3) from issue #60 were already fixed in commitdb4b9b9— this PR addresses the remaining P2.fix(knowledge): migrate qdrantsearch()→query_points()(qdrant-client ≥1.13 removedsearch; tests masked via MagicMock).chore(types): 10 files of precise type-hint fixes — no# type: ignoreblanket-suppressions, no global ruff/mypy disables. Per-file rationale in the commit message.Verification (local, W47-G)
mypy src/nss/ --ignore-missing-imports→ 0 errors (38 source files)ruff check src/ tests/→ All checks passedpytest tests/ -v→ 209/209 pass (Python 3.12, 52s, with all 10 Dependabot dep-bumps installed simultaneously: fastapi 0.136.3, pydantic 2.13.4, cryptography 48.0.0, structlog 25.5.0, redis 7.4.0, ruff 0.15.14, sentence-transformers 5.5.1, httpx 0.28.1, pytest 9.0.3, pydantic-settings 2.14.1)A33 / DEC-050 compliance
Anywidening (only inmetrics_server.kwargsand_fire_dpia.entities: list[Any]) carries an in-line code comment justifying why a narrower type would be a false positive.AttributeError), not just an annotation patch.Next (post-merge cascade)
After this lands, the W47-G plan continues with the 10 Dependabot PRs in risk order:
Test plan
test (3.11),test (3.12),build,secrets-scan,sastCloses #60 (P2).
Co-authored-by: Claude Opus 4.7 (1M context)