UAT: Pervasive # type: ignore suppression in repositories.py violates no-type-suppression rule #3680

Open
opened 2026-04-05 21:31:19 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/repositories/remove-type-ignore-suppression
  • Commit Message: fix(infrastructure): remove 329 # type: ignore suppressions from repositories.py using proper cast() patterns
  • Milestone: None (backlog — see note below)
  • Parent Epic: #946

Description

The file src/cleveragents/infrastructure/database/repositories.py contains 329 occurrences of # type: ignore comments. The project's CONTRIBUTING.md explicitly states: "The use of # type: ignore or any other mechanism to suppress or disable type checking is strictly forbidden."

What was tested

Code-level analysis of src/cleveragents/infrastructure/database/repositories.py.

Expected behavior (from CONTRIBUTING.md)

All code must pass nox -e typecheck using Pyright. The use of # type: ignore or any other mechanism to suppress or disable type checking is strictly forbidden.

Actual behavior

329 occurrences of # type: ignore are present throughout the file. Representative examples:

  • Line 160: project.id = db_project.id # type: ignore
  • Line 228: db_project.name = project.name # type: ignore
  • Line 289: plan.id = db_plan.id # type: ignore
  • Lines 1075–1098: Multiple # type: ignore[assignment] in ActionRepository.update()
  • Lines 1356–1415: Multiple # type: ignore[assignment] in LifecyclePlanRepository.update()

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., typed_column: Mapped[int] declarations or cast(int, db_obj.id)).

Steps to reproduce

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

Code location

src/cleveragents/infrastructure/database/repositories.py — 329 occurrences

Subtasks

  • Audit all 329 # type: ignore occurrences in repositories.py and categorise by root cause (ORM column type mismatch, assignment, return type, etc.)
  • Replace ORM column-to-domain-model assignments with proper cast() calls or Mapped[T] typed column declarations
  • 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 errors after all suppressions are removed
  • Verify nox -e unit_tests and nox -e integration_tests still pass
  • Verify coverage remains >= 97% (nox -e coverage_report)

Definition of Done

  • Zero # type: ignore comments remain in src/cleveragents/infrastructure/database/repositories.py
  • nox -e typecheck passes with no errors or warnings on the affected file
  • No new type suppressions introduced anywhere in the codebase as a side-effect
  • 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-suppression` - **Commit Message**: `fix(infrastructure): remove 329 # type: ignore suppressions from repositories.py using proper cast() patterns` - **Milestone**: None (backlog — see note below) - **Parent Epic**: #946 ## Description The file `src/cleveragents/infrastructure/database/repositories.py` contains **329 occurrences** of `# type: ignore` comments. The project's CONTRIBUTING.md explicitly states: *"The use of `# type: ignore` or any other mechanism to suppress or disable type checking is strictly forbidden."* ### What was tested Code-level analysis of `src/cleveragents/infrastructure/database/repositories.py`. ### Expected behavior (from CONTRIBUTING.md) All code must pass `nox -e typecheck` using Pyright. The use of `# type: ignore` or any other mechanism to suppress or disable type checking is strictly forbidden. ### Actual behavior 329 occurrences of `# type: ignore` are present throughout the file. Representative examples: - Line 160: `project.id = db_project.id # type: ignore` - Line 228: `db_project.name = project.name # type: ignore` - Line 289: `plan.id = db_plan.id # type: ignore` - Lines 1075–1098: Multiple `# type: ignore[assignment]` in `ActionRepository.update()` - Lines 1356–1415: Multiple `# type: ignore[assignment]` in `LifecyclePlanRepository.update()` ### 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., `typed_column: Mapped[int]` declarations or `cast(int, db_obj.id)`). ### Steps to reproduce ```bash grep -c "# type: ignore" src/cleveragents/infrastructure/database/repositories.py # Returns: 329 ``` ### Code location `src/cleveragents/infrastructure/database/repositories.py` — 329 occurrences ## Subtasks - [ ] Audit all 329 `# type: ignore` occurrences in `repositories.py` and categorise by root cause (ORM column type mismatch, assignment, return type, etc.) - [ ] Replace ORM column-to-domain-model assignments with proper `cast()` calls or `Mapped[T]` typed column declarations - [ ] 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 errors after all suppressions are removed - [ ] Verify `nox -e unit_tests` and `nox -e integration_tests` still pass - [ ] Verify coverage remains >= 97% (`nox -e coverage_report`) ## Definition of Done - [ ] Zero `# type: ignore` comments remain in `src/cleveragents/infrastructure/database/repositories.py` - [ ] `nox -e typecheck` passes with no errors or warnings on the affected file - [ ] No new type suppressions introduced anywhere in the codebase as a side-effect - [ ] 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

Issue triaged by project owner:

  • State: Verified
  • Priority: Backlog — While CONTRIBUTING.md says type suppression is "strictly forbidden," this is a large refactoring effort (329 occurrences) that doesn't change runtime behavior. It improves type safety but doesn't fix a user-facing bug.
  • Milestone: None (backlog — this is a significant refactoring effort best scheduled when there's capacity)
  • Story Points: 13 — XXL — 329 occurrences across a large file requiring careful SQLAlchemy ORM typing patterns. Each suppression needs individual analysis to determine the correct cast() or Mapped[T] replacement. High risk of introducing regressions.
  • MoSCoW: Should Have — CONTRIBUTING.md explicitly forbids # type: ignore. This is a code quality standard violation that should be addressed, but it doesn't change runtime behavior and can be deferred without blocking milestones.
  • Parent Epic: #946

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: Backlog — While CONTRIBUTING.md says type suppression is "strictly forbidden," this is a large refactoring effort (329 occurrences) that doesn't change runtime behavior. It improves type safety but doesn't fix a user-facing bug. - **Milestone**: None (backlog — this is a significant refactoring effort best scheduled when there's capacity) - **Story Points**: 13 — XXL — 329 occurrences across a large file requiring careful SQLAlchemy ORM typing patterns. Each suppression needs individual analysis to determine the correct `cast()` or `Mapped[T]` replacement. High risk of introducing regressions. - **MoSCoW**: Should Have — CONTRIBUTING.md explicitly forbids `# type: ignore`. This is a code quality standard violation that should be addressed, but it doesn't change runtime behavior and can be deferred without blocking milestones. - **Parent Epic**: #946 --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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.

Reference
cleveragents/cleveragents-core#3680
No description provided.