Forbidden # type: ignore[assignment] annotation in actor.py CLI add command #8438

Open
opened 2026-04-13 18:53:28 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit message: Build: Reinforced label enforcement, and ensure implementation workers dont continue work on a mergable PR.
  • Branch: master

Background and Context

The code quality standards explicitly state: "type: ignore is FORBIDDEN". In src/cleveragents/cli/commands/actor.py, the add() command contains a # type: ignore[assignment] annotation:

# Extract schema_version from the parsed config blob if present.
schema_version: str | None = config_blob.get("schema_version")  # type: ignore[assignment]
if schema_version and not isinstance(schema_version, str):
    schema_version = str(schema_version)

The config_blob.get("schema_version") returns Any (since config_blob is typed as dict[str, Any]), but the variable is annotated as str | None. The type checker correctly flags this as an assignment error because Any is not narrowed to str | None. Instead of fixing the type annotation or adding a proper runtime cast, the code suppresses the type error with # type: ignore[assignment].

The subsequent isinstance check is correct defensive code, but the type: ignore suppression masks the underlying type annotation issue and violates the project's type safety standards.

Current Behavior

The # type: ignore[assignment] suppresses a legitimate type checker warning. The actual runtime behavior is correct (the isinstance guard handles non-string values), but the type annotation is incorrect and the suppression hides this from static analysis.

Expected Behavior

Per the code quality standards:

  • # type: ignore is forbidden in all forms.
  • The correct fix is to use cast() or a proper type annotation that reflects the actual return type of dict[str, Any].get().
  • Example fix:
    schema_version_raw = config_blob.get("schema_version")
    schema_version: str | None = str(schema_version_raw) if schema_version_raw is not None else None
    

Acceptance Criteria

  • The # type: ignore[assignment] annotation is removed from src/cleveragents/cli/commands/actor.py.
  • The schema_version variable has a correct type annotation that satisfies the type checker without suppression.
  • mypy / pyright typecheck passes with no new errors.
  • The agents actor add command continues to work correctly.
  • nox passes (all sessions including typecheck).
  • Coverage remains ≥ 97%.

Subtasks

  • Remove # type: ignore[assignment] from the schema_version assignment
  • Fix the type annotation to correctly reflect the runtime type
  • Verify nox -s typecheck passes with no new errors
  • Run nox and confirm all sessions pass

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message is fix(types): remove forbidden type: ignore annotation from actor add command, followed by a blank line, then additional details, and a footer ISSUES CLOSED: #<this issue number>.
  • The commit is pushed to a branch and submitted as a pull request to master, reviewed, and merged.
  • All nox stages pass and coverage ≥ 97%.

Automated by CleverAgents Bot
Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor

## Metadata - **Commit message**: `Build: Reinforced label enforcement, and ensure implementation workers dont continue work on a mergable PR.` - **Branch**: `master` ## Background and Context The code quality standards explicitly state: **"type: ignore is FORBIDDEN"**. In `src/cleveragents/cli/commands/actor.py`, the `add()` command contains a `# type: ignore[assignment]` annotation: ```python # Extract schema_version from the parsed config blob if present. schema_version: str | None = config_blob.get("schema_version") # type: ignore[assignment] if schema_version and not isinstance(schema_version, str): schema_version = str(schema_version) ``` The `config_blob.get("schema_version")` returns `Any` (since `config_blob` is typed as `dict[str, Any]`), but the variable is annotated as `str | None`. The type checker correctly flags this as an assignment error because `Any` is not narrowed to `str | None`. Instead of fixing the type annotation or adding a proper runtime cast, the code suppresses the type error with `# type: ignore[assignment]`. The subsequent `isinstance` check is correct defensive code, but the `type: ignore` suppression masks the underlying type annotation issue and violates the project's type safety standards. ## Current Behavior The `# type: ignore[assignment]` suppresses a legitimate type checker warning. The actual runtime behavior is correct (the `isinstance` guard handles non-string values), but the type annotation is incorrect and the suppression hides this from static analysis. ## Expected Behavior Per the code quality standards: - `# type: ignore` is forbidden in all forms. - The correct fix is to use `cast()` or a proper type annotation that reflects the actual return type of `dict[str, Any].get()`. - Example fix: ```python schema_version_raw = config_blob.get("schema_version") schema_version: str | None = str(schema_version_raw) if schema_version_raw is not None else None ``` ## Acceptance Criteria - [ ] The `# type: ignore[assignment]` annotation is removed from `src/cleveragents/cli/commands/actor.py`. - [ ] The `schema_version` variable has a correct type annotation that satisfies the type checker without suppression. - [ ] `mypy` / `pyright` typecheck passes with no new errors. - [ ] The `agents actor add` command continues to work correctly. - [ ] `nox` passes (all sessions including `typecheck`). - [ ] Coverage remains ≥ 97%. ## Subtasks - [ ] Remove `# type: ignore[assignment]` from the `schema_version` assignment - [ ] Fix the type annotation to correctly reflect the runtime type - [ ] Verify `nox -s typecheck` passes with no new errors - [ ] Run `nox` and confirm all sessions pass ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message is `fix(types): remove forbidden type: ignore annotation from actor add command`, followed by a blank line, then additional details, and a footer `ISSUES CLOSED: #<this issue number>`. - The commit is pushed to a branch and submitted as a pull request to `master`, reviewed, and merged. - All nox stages pass and coverage ≥ 97%. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor
HAL9000 added this to the v3.6.0 milestone 2026-04-13 19:14:32 +00:00
HAL9000 modified the milestone from v3.6.0 to v3.2.0 2026-04-13 20:13:32 +00:00
Author
Owner

[AUTO-OWNR-2] Triage Decision

Status: Verified

MoSCoW: Should Have
Priority: Low

Rationale: The use of # type: ignore[assignment] in actor.py's add() command is an explicit violation of the project's Code Quality Standards, which state that type: ignore is FORBIDDEN in all forms. The suppression masks a legitimate type annotation issue (dict[str, Any].get() returning Any being assigned to str | None) and undermines static analysis integrity. While the runtime behavior is correct due to the subsequent isinstance guard, the type suppression must be removed and replaced with a proper cast or annotation. This is a Should Have code quality fix — important for standards compliance but not blocking any milestone feature.

Next Steps: Remove the # type: ignore[assignment] annotation and replace the schema_version assignment with a proper type-safe pattern (e.g., schema_version_raw = config_blob.get("schema_version"); schema_version: str | None = str(schema_version_raw) if schema_version_raw is not None else None). Verify nox -s typecheck passes with no new errors and all nox sessions pass. This can be batched with the related fix in #8460 for a single clean actor.py code quality PR.


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

## [AUTO-OWNR-2] Triage Decision **Status**: ✅ Verified **MoSCoW**: Should Have **Priority**: Low **Rationale**: The use of `# type: ignore[assignment]` in `actor.py`'s `add()` command is an explicit violation of the project's Code Quality Standards, which state that `type: ignore` is **FORBIDDEN** in all forms. The suppression masks a legitimate type annotation issue (`dict[str, Any].get()` returning `Any` being assigned to `str | None`) and undermines static analysis integrity. While the runtime behavior is correct due to the subsequent `isinstance` guard, the type suppression must be removed and replaced with a proper cast or annotation. This is a Should Have code quality fix — important for standards compliance but not blocking any milestone feature. **Next Steps**: Remove the `# type: ignore[assignment]` annotation and replace the `schema_version` assignment with a proper type-safe pattern (e.g., `schema_version_raw = config_blob.get("schema_version"); schema_version: str | None = str(schema_version_raw) if schema_version_raw is not None else None`). Verify `nox -s typecheck` passes with no new errors and all nox sessions pass. This can be batched with the related fix in #8460 for a single clean `actor.py` code quality PR. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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.

Dependencies

No dependencies set.

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