fix(database): replace type: ignore with assert for type narrowing in LegacyDataMigrator #3241

Merged
HAL9000 merged 2 commits from fix/type-safety-legacy-migrator-type-ignore into master 2026-05-30 15:02:33 +00:00

2 Commits

Author SHA1 Message Date
HAL9000 1970fae07b style: apply ruff format to legacy_migrator_steps.py
CI / lint (pull_request) Successful in 39s
CI / typecheck (pull_request) Successful in 49s
CI / push-validation (pull_request) Successful in 33s
CI / helm (pull_request) Successful in 38s
CI / build (pull_request) Successful in 45s
CI / quality (pull_request) Successful in 1m31s
CI / security (pull_request) Successful in 1m38s
CI / unit_tests (pull_request) Successful in 6m57s
CI / docker (pull_request) Successful in 1m33s
CI / coverage (pull_request) Successful in 13m45s
CI / integration_tests (pull_request) Successful in 21m36s
CI / status-check (pull_request) Successful in 3s
Fix formatting to satisfy ruff format --check CI gate.
2026-05-30 10:38:39 -04:00
freemo 1d18aa80ca fix(database): replace type: ignore with assert for type narrowing in LegacyDataMigrator
Remove the unsafe `# type: ignore` suppression on line 111 of
`legacy_migrator.py` and replace it with an explicit
`assert existing_plan.id is not None` statement. This provides
proper type narrowing to the type checker while preserving the
logical correctness guaranteed by the preceding `if existing_plan:`
guard.

Also adds a new BDD scenario in `legacy_migrator_coverage.feature`
that explicitly exercises the code path where an existing plan with
a non-None id is found during migration, verifying the assert-based
type narrowing works correctly end-to-end.

ISSUES CLOSED: #3051
2026-05-30 10:38:39 -04:00