fix(mypy): replace 6 unjustified in-scope type: ignore masks with code fixes #156

Closed
Mark wants to merge 1 commit from fix/116-verify-clean-mypy-fixes into main
Owner

Summary

  • Replaces six bare in-scope mypy ignores with explicit runtime/type fixes.
  • Uses ColumnElement casts at the two SQLAlchemy order_by() boundaries.
  • Leaves the three unrelated celery_task_id ignores untouched; they remain [unused-ignore] and are out of scope.

Files

  • backend/app/services/investigations/runbooks.py
  • backend/app/routers/investigations.py

Verification

  • Branch commit: 1126cb4
  • git diff --check origin/main...HEAD: clean
  • Focused target-file mypy check: zero in-scope errors (assignment, arg-type, return-value, attr-defined, misc, valid-type, call-arg); remaining target-file findings are unrelated [unused-ignore] / [no-any-return].
  • ruff check .: passed.
  • Full-repo mypy currently reports unrelated errors introduced after this branch base; this PR does not address those out-of-scope files.

Task linkage

  • Kanban task: t_8b3bc6a2
  • Parent verification card: t_3c2e1d0a
## Summary - Replaces six bare in-scope `mypy` ignores with explicit runtime/type fixes. - Uses `ColumnElement` casts at the two SQLAlchemy `order_by()` boundaries. - Leaves the three unrelated `celery_task_id` ignores untouched; they remain `[unused-ignore]` and are out of scope. ## Files - `backend/app/services/investigations/runbooks.py` - `backend/app/routers/investigations.py` ## Verification - Branch commit: `1126cb4` - `git diff --check origin/main...HEAD`: clean - Focused target-file mypy check: zero in-scope errors (`assignment`, `arg-type`, `return-value`, `attr-defined`, `misc`, `valid-type`, `call-arg`); remaining target-file findings are unrelated `[unused-ignore]` / `[no-any-return]`. - `ruff check .`: passed. - Full-repo mypy currently reports unrelated errors introduced after this branch base; this PR does not address those out-of-scope files. ## Task linkage - Kanban task: `t_8b3bc6a2` - Parent verification card: `t_3c2e1d0a`
fix(mypy): replace 6 unjustified in-scope type: ignore masks with code fixes
Some checks failed
CI / Frontend Lint (pull_request) Failing after 25s
CI / Frontend Tests (pull_request) Has been skipped
Performance Regression Tests / Performance Regression Detection (pull_request) Failing after 1m2s
Performance Regression Tests / Compare with Baseline (pull_request) Has been skipped
Stress Tests / Stress & Pipeline Tests (pull_request) Failing after 7s
Stress Tests / Full Data Pipeline Validation (pull_request) Has been skipped
CI / Backend Lint & Format (pull_request) Failing after 2m6s
CI / Golden Fixture Validation (pull_request) Has been skipped
CI / Backend Tests (pull_request) Has been skipped
CI / Backend Security Tests (pull_request) Has been skipped
CI / Dependency Security Scan (pull_request) Has been skipped
CI / Frontend E2E Tests (pull_request) Has been skipped
CI / All Checks Passed (pull_request) Failing after 16s
1126cb4e14
PR #124 (commit 9176d7f) cleared every in-scope mypy error reported by
mypy, but six pre-existing bare '# type: ignore' comments continued to
silently mask in-scope errors that the original audit (t_32c522a2) didn't
catalog (the audit ran on a mypy log, so silent ignores were invisible).
PR #124 did not touch these lines.

This change clears the 6 masks with code fixes in the same style as PR
#124, each carrying an inline justification comment naming the mypy code
and the reason for the change:

- runbooks.py:18 [assignment]
  options: dict[str, Any] = None  ->  options: dict[str, Any] | None = None
  (no_implicit_optional=True forbids the implicit-Optional shorthand)

- investigations.py:114 [arg-type]
  run_investigation.delay(int(run.id))
    -> assert run.id is not None; run_investigation.delay(run.id)
  (SQLModel PK is Optional[int]; session.refresh() populated it)

- investigations.py:174 [arg-type]
  .order_by(InvestigationStep.step_number)
    -> .order_by(cast(ColumnElement, InvestigationStep.step_number))
  (step_number is typed int; cast for the .order_by() ColumnElement slot)

- investigations.py:241 [arg-type]   (same pattern as :114)
- investigations.py:265 [arg-type]   (same pattern as :114)
- investigations.py:289 [arg-type]
  .order_by(InvestigationRun.created_at)
    -> .order_by(cast(ColumnElement, InvestigationRun.created_at))
  (created_at is typed datetime; cast for the .order_by() slot)

Verification:
  - mypy on backend/app/ reports 0 in-scope errors at the six sites;
    net file count delta vs origin/main is 0 (150 -> 150).
  - ruff check on the two files: All checks passed.
  - pytest on touched test files (test_investigations_api,
    test_investigation_orchestrator, test_investigations_persistence,
    test_investigation_artifact_chunking, test_investigation_entity_tools,
    test_followup_investigation_triggers, test_entity_investigation):
    101 passed, 0 failed (excluding the pre-existing infra failure in
    test_database_fixtures::test_test_settings_fixture, which fails
    identically on origin/main and is unrelated to this change).

Refs:
  - kanban t_3c2e1d0a (verify-clean-mypy acceptance criterion)
  - kanban t_4cc4901a (fixup-card this implementation lands)
  - Mark/osint-hub#116 (Real-bug bucket closure)
  - Mark/osint-hub#117 (var-annotated bucket, adjacent work)
Mark closed this pull request 2026-09-21 01:08:46 +00:00
Some checks failed
CI / Frontend Lint (pull_request) Failing after 25s
CI / Frontend Tests (pull_request) Has been skipped
Performance Regression Tests / Performance Regression Detection (pull_request) Failing after 1m2s
Performance Regression Tests / Compare with Baseline (pull_request) Has been skipped
Stress Tests / Stress & Pipeline Tests (pull_request) Failing after 7s
Stress Tests / Full Data Pipeline Validation (pull_request) Has been skipped
CI / Backend Lint & Format (pull_request) Failing after 2m6s
CI / Golden Fixture Validation (pull_request) Has been skipped
CI / Backend Tests (pull_request) Has been skipped
CI / Backend Security Tests (pull_request) Has been skipped
CI / Dependency Security Scan (pull_request) Has been skipped
CI / Frontend E2E Tests (pull_request) Has been skipped
CI / All Checks Passed (pull_request) Failing after 16s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/osint-hub!156
No description provided.