UAT: 329 prohibited # type: ignore comments in infrastructure/database/repositories.py violate CONTRIBUTING.md type safety policy #3797

Closed
opened 2026-04-06 06:23:22 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/repositories/remove-type-ignore-suppressions-329
  • Commit Message: fix(infrastructure): remove all 329 # type: ignore suppressions from repositories.py
  • Milestone: None (backlog — see note below)
  • Parent Epic: #362

Description

The file src/cleveragents/infrastructure/database/repositories.py contains 329 instances of # type: ignore comments. CONTRIBUTING.md explicitly prohibits this under the "Type Safety" section:

"No Suppression: When a static type checker is in use, never disable it via configuration files and never use inline comments or annotations to suppress individual type checking errors (e.g., no type: ignore, noinspection, @SuppressWarnings, or equivalent directives)."

The # type: ignore comments appear throughout the repository implementations, primarily when accessing SQLAlchemy ORM model attributes (e.g., db_project.id # type: ignore, db_project.name # type: ignore). These suppressions hide potential type errors and violate the project's strict type safety policy.

Expected behavior

All code should pass nox -e typecheck (Pyright) without any # type: ignore suppressions. SQLAlchemy model attributes should be properly typed using Mapped[T] annotations or equivalent.

Actual behavior

329 # type: ignore comments exist in src/cleveragents/infrastructure/database/repositories.py, suppressing type errors throughout the repository layer.

Steps to reproduce

grep -c "# type: ignore" src/cleveragents/infrastructure/database/repositories.py
# Output: 329

Root cause

SQLAlchemy ORM column attributes are typed as Column[T] but assigned to plain Python types. The code uses # type: ignore as a workaround instead of proper cast() calls or typed column access patterns (e.g., Mapped[int] declarations or cast(int, db_obj.id)).

Code location

cleveragents.infrastructure.database.repositories — throughout all repository classes:

  • ProjectRepository, PlanRepository, ContextRepository, ChangeRepository
  • DebugAttemptRepository, ActorRepository, ActionRepository
  • LifecyclePlanRepository, ResourceTypeRepository, ResourceRepository
  • NamespacedProjectRepository, ToolRegistryRepository, SkillRepository
  • DecisionRepository, CheckpointRepository, CorrectionAttemptRepository
  • and others

⚠️ Potential duplicate: Issue #3680 ("UAT: Pervasive # type: ignore suppression in repositories.py violates no-type-suppression rule") covers the same underlying bug. A human reviewer should assess whether this issue should be closed as a duplicate of #3680 or vice versa.

Subtasks

  • Audit all 329 # type: ignore occurrences in repositories.py and categorise by root cause (ORM column type mismatch, assignment, return type, etc.)
  • Update SQLAlchemy ORM model column declarations to use Mapped[T] typed annotations (e.g., id: Mapped[int], name: Mapped[str]) so attribute access is correctly typed
  • Replace ORM column-to-domain-model assignments with proper cast() calls where Mapped[T] declarations are not sufficient
  • Replace all # type: ignore[assignment] patterns in update() methods (e.g., ActionRepository.update(), LifecyclePlanRepository.update()) with correctly typed attribute access
  • Verify nox -e typecheck passes with zero Pyright errors after all suppressions are removed
  • Verify nox -e unit_tests and nox -e integration_tests still pass with no regressions
  • Verify coverage remains >= 97% (nox -e coverage_report)
  • Confirm zero # type: ignore comments remain in src/cleveragents/infrastructure/database/repositories.py

Definition of Done

  • Zero # type: ignore comments remain in src/cleveragents/infrastructure/database/repositories.py
  • nox -e typecheck passes with no Pyright errors or warnings on the affected file
  • No new type suppressions introduced anywhere in the codebase as a side-effect of this fix
  • All nox stages pass
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.6.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/repositories/remove-type-ignore-suppressions-329` - **Commit Message**: `fix(infrastructure): remove all 329 # type: ignore suppressions from repositories.py` - **Milestone**: None (backlog — see note below) - **Parent Epic**: #362 ## Description The file `src/cleveragents/infrastructure/database/repositories.py` contains **329 instances** of `# type: ignore` comments. CONTRIBUTING.md explicitly prohibits this under the "Type Safety" section: > "No Suppression: When a static type checker is in use, never disable it via configuration files and never use inline comments or annotations to suppress individual type checking errors (e.g., no `type: ignore`, `noinspection`, `@SuppressWarnings`, or equivalent directives)." The `# type: ignore` comments appear throughout the repository implementations, primarily when accessing SQLAlchemy ORM model attributes (e.g., `db_project.id # type: ignore`, `db_project.name # type: ignore`). These suppressions hide potential type errors and violate the project's strict type safety policy. ### Expected behavior All code should pass `nox -e typecheck` (Pyright) without any `# type: ignore` suppressions. SQLAlchemy model attributes should be properly typed using `Mapped[T]` annotations or equivalent. ### Actual behavior 329 `# type: ignore` comments exist in `src/cleveragents/infrastructure/database/repositories.py`, suppressing type errors throughout the repository layer. ### Steps to reproduce ```bash grep -c "# type: ignore" src/cleveragents/infrastructure/database/repositories.py # Output: 329 ``` ### Root cause SQLAlchemy ORM column attributes are typed as `Column[T]` but assigned to plain Python types. The code uses `# type: ignore` as a workaround instead of proper `cast()` calls or typed column access patterns (e.g., `Mapped[int]` declarations or `cast(int, db_obj.id)`). ### Code location `cleveragents.infrastructure.database.repositories` — throughout all repository classes: - `ProjectRepository`, `PlanRepository`, `ContextRepository`, `ChangeRepository` - `DebugAttemptRepository`, `ActorRepository`, `ActionRepository` - `LifecyclePlanRepository`, `ResourceTypeRepository`, `ResourceRepository` - `NamespacedProjectRepository`, `ToolRegistryRepository`, `SkillRepository` - `DecisionRepository`, `CheckpointRepository`, `CorrectionAttemptRepository` - and others > ⚠️ **Potential duplicate**: Issue #3680 ("UAT: Pervasive `# type: ignore` suppression in repositories.py violates no-type-suppression rule") covers the same underlying bug. A human reviewer should assess whether this issue should be closed as a duplicate of #3680 or vice versa. ## Subtasks - [ ] Audit all 329 `# type: ignore` occurrences in `repositories.py` and categorise by root cause (ORM column type mismatch, assignment, return type, etc.) - [ ] Update SQLAlchemy ORM model column declarations to use `Mapped[T]` typed annotations (e.g., `id: Mapped[int]`, `name: Mapped[str]`) so attribute access is correctly typed - [ ] Replace ORM column-to-domain-model assignments with proper `cast()` calls where `Mapped[T]` declarations are not sufficient - [ ] Replace all `# type: ignore[assignment]` patterns in `update()` methods (e.g., `ActionRepository.update()`, `LifecyclePlanRepository.update()`) with correctly typed attribute access - [ ] Verify `nox -e typecheck` passes with zero Pyright errors after all suppressions are removed - [ ] Verify `nox -e unit_tests` and `nox -e integration_tests` still pass with no regressions - [ ] Verify coverage remains >= 97% (`nox -e coverage_report`) - [ ] Confirm zero `# type: ignore` comments remain in `src/cleveragents/infrastructure/database/repositories.py` ## Definition of Done - [ ] Zero `# type: ignore` comments remain in `src/cleveragents/infrastructure/database/repositories.py` - [ ] `nox -e typecheck` passes with no Pyright errors or warnings on the affected file - [ ] No new type suppressions introduced anywhere in the codebase as a side-effect of this fix - [ ] All nox stages pass - [ ] Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.6.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
Author
Owner

This issue is a duplicate of #3680 which was filed by a previous UAT tester instance. Closing as duplicate.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

This issue is a duplicate of #3680 which was filed by a previous UAT tester instance. Closing as duplicate. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Sign in to join this conversation.
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.

Blocks
#362 Epic: Security & Safety Hardening
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3797
No description provided.