UAT: 31 # type: ignore[misc] comments on SQLAlchemy ORM model classes in infrastructure/database/models.py violate the no-type-ignore rule #2395

Open
opened 2026-04-03 17:31:25 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/remove-type-ignore-sqlalchemy-orm-models
  • Commit Message: fix(database): remove 31 type: ignore[misc] suppressions from SQLAlchemy ORM model classes
  • Milestone: v3.7.0
  • Parent Epic: #362

Background

The project rules (CONTRIBUTING.md) explicitly state: "The use of # type: ignore or any other mechanism to disable or suppress type checking is strictly prohibited." Every SQLAlchemy ORM model class in src/cleveragents/infrastructure/database/models.py currently carries a # type: ignore[misc] comment on its class definition line, directly violating this policy.

These suppressions were added to silence Pyright's misc error that arises when SQLAlchemy's legacy declarative_base() pattern is used without proper type stubs. The correct fix is to migrate to SQLAlchemy 2.0's DeclarativeBase with Mapped[] annotations — a pattern already correctly used by LockModel on line 2629 — or to configure Pyright appropriately to handle the metaclass pattern without suppression.

Current Behavior

Every SQLAlchemy ORM model class in src/cleveragents/infrastructure/database/models.py has a # type: ignore[misc] comment on its class definition line. There are 31 violations:

Line 250:  class LifecycleActionModel(Base):  # type: ignore[misc]
Line 507:  class ActionInvariantModel(Base):  # type: ignore[misc]
Line 533:  class ActionArgumentModel(Base):  # type: ignore[misc]
Line 565:  class LifecyclePlanModel(Base):  # type: ignore[misc]
Line 1173: class PlanProjectModel(Base):  # type: ignore[misc]
Line 1200: class PlanArgumentModel(Base):  # type: ignore[misc]
Line 1227: class PlanInvariantModel(Base):  # type: ignore[misc]
Line 1260: class NamespacedProjectModel(Base):  # type: ignore[misc]
Line 1394: class ProjectResourceLinkModel(Base):  # type: ignore[misc]
Line 1463: class ResourceTypeModel(Base):  # type: ignore[misc]
Line 1532: class ResourceModel(Base):  # type: ignore[misc]
Line 1616: class ResourceEdgeModel(Base):  # type: ignore[misc]
Line 1681: class ResourceLinkModel(Base):  # type: ignore[misc]
Line 1726: class ToolModel(Base):  # type: ignore[misc]
Line 1929: class ToolResourceBindingModel(Base):  # type: ignore[misc]
Line 1969: class ValidationAttachmentModel(Base):  # type: ignore[misc]
Line 2029: class SessionModel(Base):  # type: ignore[misc]
Line 2145: class SessionMessageModel(Base):  # type: ignore[misc]
Line 2232: class AutomationProfileModel(Base):  # type: ignore[misc]
Line 2278: class AuditLogModel(Base):  # type: ignore[misc]
Line 2331: class SkillModel(Base):  # type: ignore[misc]
Line 2588: class SkillItemModel(Base):  # type: ignore[misc]
Line 2629: class LockModel(Base):  # type: ignore[misc]
Line 2665: class DecisionModel(Base):  # type: ignore[misc]
Line 2905: class DecisionDependencyModel(Base):  # type: ignore[misc]
Line 2948: class CheckpointModel(Base):  # type: ignore[misc]
Line 3106: class CorrectionAttemptModel(Base):  # type: ignore[misc]
Line 3331: class ChangeSetEntryModel(Base):  # type: ignore[misc]
Line 3365: class ToolInvocationModel(Base):  # type: ignore[misc]
Line 3410: class LLMTraceModel(Base):  # type: ignore[misc]
Line 3454: class AsyncJobModel(Base):  # type: ignore[misc]

Expected Behavior

No # type: ignore comments anywhere in the codebase. All code must pass nox -e typecheck (Pyright) without any suppression. The correct approach is one of:

  1. Preferred: Migrate all ORM model classes to use SQLAlchemy 2.0's DeclarativeBase with Mapped[] annotations (as already done for LockModel), which is natively understood by Pyright without suppression.
  2. Alternative: Add a Pyright configuration entry (e.g., reportMiscIssues = false scoped to this module) — though this is less preferred as it still suppresses checking rather than fixing the root cause.

Subtasks

  • Audit all 31 class definitions in src/cleveragents/infrastructure/database/models.py to confirm the # type: ignore[misc] pattern
  • Migrate the Base declaration from declarative_base() to SQLAlchemy 2.0's DeclarativeBase subclass pattern
  • Update all 31 ORM model classes to use Mapped[] annotations and remove # type: ignore[misc] comments
  • Verify nox -e typecheck passes with zero suppression after the migration
  • Verify nox -e unit_tests passes (no regressions from ORM model changes)
  • Verify nox -e integration_tests passes (no regressions from ORM model changes)
  • Verify nox -e coverage_report shows coverage >= 97%

Definition of Done

  • All 31 # type: ignore[misc] comments removed from src/cleveragents/infrastructure/database/models.py
  • nox -e typecheck passes with zero type-ignore suppressions in the file
  • nox -e unit_tests passes with no regressions
  • nox -e integration_tests passes with no regressions
  • All nox stages pass
  • Coverage >= 97%

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

## Metadata - **Branch**: `fix/remove-type-ignore-sqlalchemy-orm-models` - **Commit Message**: `fix(database): remove 31 type: ignore[misc] suppressions from SQLAlchemy ORM model classes` - **Milestone**: v3.7.0 - **Parent Epic**: #362 ## Background The project rules (`CONTRIBUTING.md`) explicitly state: *"The use of `# type: ignore` or any other mechanism to disable or suppress type checking is strictly prohibited."* Every SQLAlchemy ORM model class in `src/cleveragents/infrastructure/database/models.py` currently carries a `# type: ignore[misc]` comment on its class definition line, directly violating this policy. These suppressions were added to silence Pyright's `misc` error that arises when SQLAlchemy's legacy `declarative_base()` pattern is used without proper type stubs. The correct fix is to migrate to SQLAlchemy 2.0's `DeclarativeBase` with `Mapped[]` annotations — a pattern already correctly used by `LockModel` on line 2629 — or to configure Pyright appropriately to handle the metaclass pattern without suppression. ## Current Behavior Every SQLAlchemy ORM model class in `src/cleveragents/infrastructure/database/models.py` has a `# type: ignore[misc]` comment on its class definition line. There are **31 violations**: ``` Line 250: class LifecycleActionModel(Base): # type: ignore[misc] Line 507: class ActionInvariantModel(Base): # type: ignore[misc] Line 533: class ActionArgumentModel(Base): # type: ignore[misc] Line 565: class LifecyclePlanModel(Base): # type: ignore[misc] Line 1173: class PlanProjectModel(Base): # type: ignore[misc] Line 1200: class PlanArgumentModel(Base): # type: ignore[misc] Line 1227: class PlanInvariantModel(Base): # type: ignore[misc] Line 1260: class NamespacedProjectModel(Base): # type: ignore[misc] Line 1394: class ProjectResourceLinkModel(Base): # type: ignore[misc] Line 1463: class ResourceTypeModel(Base): # type: ignore[misc] Line 1532: class ResourceModel(Base): # type: ignore[misc] Line 1616: class ResourceEdgeModel(Base): # type: ignore[misc] Line 1681: class ResourceLinkModel(Base): # type: ignore[misc] Line 1726: class ToolModel(Base): # type: ignore[misc] Line 1929: class ToolResourceBindingModel(Base): # type: ignore[misc] Line 1969: class ValidationAttachmentModel(Base): # type: ignore[misc] Line 2029: class SessionModel(Base): # type: ignore[misc] Line 2145: class SessionMessageModel(Base): # type: ignore[misc] Line 2232: class AutomationProfileModel(Base): # type: ignore[misc] Line 2278: class AuditLogModel(Base): # type: ignore[misc] Line 2331: class SkillModel(Base): # type: ignore[misc] Line 2588: class SkillItemModel(Base): # type: ignore[misc] Line 2629: class LockModel(Base): # type: ignore[misc] Line 2665: class DecisionModel(Base): # type: ignore[misc] Line 2905: class DecisionDependencyModel(Base): # type: ignore[misc] Line 2948: class CheckpointModel(Base): # type: ignore[misc] Line 3106: class CorrectionAttemptModel(Base): # type: ignore[misc] Line 3331: class ChangeSetEntryModel(Base): # type: ignore[misc] Line 3365: class ToolInvocationModel(Base): # type: ignore[misc] Line 3410: class LLMTraceModel(Base): # type: ignore[misc] Line 3454: class AsyncJobModel(Base): # type: ignore[misc] ``` ## Expected Behavior No `# type: ignore` comments anywhere in the codebase. All code must pass `nox -e typecheck` (Pyright) without any suppression. The correct approach is one of: 1. **Preferred**: Migrate all ORM model classes to use SQLAlchemy 2.0's `DeclarativeBase` with `Mapped[]` annotations (as already done for `LockModel`), which is natively understood by Pyright without suppression. 2. **Alternative**: Add a Pyright configuration entry (e.g., `reportMiscIssues = false` scoped to this module) — though this is less preferred as it still suppresses checking rather than fixing the root cause. ## Subtasks - [ ] Audit all 31 class definitions in `src/cleveragents/infrastructure/database/models.py` to confirm the `# type: ignore[misc]` pattern - [ ] Migrate the `Base` declaration from `declarative_base()` to SQLAlchemy 2.0's `DeclarativeBase` subclass pattern - [ ] Update all 31 ORM model classes to use `Mapped[]` annotations and remove `# type: ignore[misc]` comments - [ ] Verify `nox -e typecheck` passes with zero suppression after the migration - [ ] Verify `nox -e unit_tests` passes (no regressions from ORM model changes) - [ ] Verify `nox -e integration_tests` passes (no regressions from ORM model changes) - [ ] Verify `nox -e coverage_report` shows coverage >= 97% ## Definition of Done - [ ] All 31 `# type: ignore[misc]` comments removed from `src/cleveragents/infrastructure/database/models.py` - [ ] `nox -e typecheck` passes with zero type-ignore suppressions in the file - [ ] `nox -e unit_tests` passes with no regressions - [ ] `nox -e integration_tests` passes with no regressions - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-03 17:31:29 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — 31 # type: ignore[misc] comments violate the project's strict no-type-ignore rule (CONTRIBUTING.md). This is a code quality/compliance issue.
  • Milestone: v3.7.0
  • MoSCoW: Should Have — The no-type-ignore rule is a project invariant. These suppressions should be removed, but they don't affect runtime behavior.
  • Parent Epic: #362 (Security & Safety Hardening)

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

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — 31 `# type: ignore[misc]` comments violate the project's strict no-type-ignore rule (CONTRIBUTING.md). This is a code quality/compliance issue. - **Milestone**: v3.7.0 - **MoSCoW**: Should Have — The no-type-ignore rule is a project invariant. These suppressions should be removed, but they don't affect runtime behavior. - **Parent Epic**: #362 (Security & Safety Hardening) --- **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.

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