UAT: Forbidden # type: ignore comments present in decomposition_service.py and decomposition_clustering.py #3754

Open
opened 2026-04-05 22:28:54 +00:00 by freemo · 0 comments
Owner

Background and Context

The project's CONTRIBUTING.md strictly forbids the use of # type: ignore or any other mechanism to suppress type-checking errors. The rule states:

No Type Ignores: The use of # type: ignore or any other mechanism to suppress type-checking errors is strictly forbidden.

Two files in application/services/ contain # type: ignore[arg-type] comments that violate this policy.

Current Behavior

File 1: src/cleveragents/application/services/decomposition_service.py, line 79:

return max(counts, key=counts.get)  # type: ignore[arg-type]

File 2: src/cleveragents/application/services/decomposition_clustering.py, line 204:

dominant = max(ext_counts, key=ext_counts.get, default="")  # type: ignore[arg-type]

Both suppressions are for the same underlying issue: dict.get has a return type of V | None (where V is the value type), but max()'s key parameter expects a callable that returns a comparable type. Pyright flags this because None is not comparable.

Expected Behavior

The # type: ignore comments should be removed and the code should be refactored to be properly typed. For example:

# Option 1: Use a lambda with a default
return max(counts, key=lambda k: counts.get(k) or 0)

# Option 2: Use operator.itemgetter
import operator
return max(counts, key=operator.itemgetter)

# Option 3: Use counts.__getitem__ directly (since all keys exist in the dict)
return max(counts, key=counts.__getitem__)

Code Locations

  1. src/cleveragents/application/services/decomposition_service.py, line 79 (in _dominant_extension function)
  2. src/cleveragents/application/services/decomposition_clustering.py, line 204 (in ClusteringStrategy.deterministic_sort method)

Steps to Reproduce

grep -n "type: ignore" src/cleveragents/application/services/decomposition_service.py
# Line 79: return max(counts, key=counts.get)  # type: ignore[arg-type]

grep -n "type: ignore" src/cleveragents/application/services/decomposition_clustering.py
# Line 204: dominant = max(ext_counts, key=ext_counts.get, default="")  # type: ignore[arg-type]

Metadata

  • Branch: fix/decomposition-type-ignore
  • Commit Message: fix(decomposition): remove forbidden type: ignore suppressions
  • Milestone: (none — backlog)
  • Parent Epic: #368

Subtasks

  • Fix _dominant_extension in decomposition_service.py to remove # type: ignore
  • Fix deterministic_sort in decomposition_clustering.py to remove # type: ignore
  • Run nox -e typecheck to verify pyright passes without suppressions
  • Run nox to verify all tests pass

Definition of Done

  • No # type: ignore comments in either file
  • nox -e typecheck passes
  • nox passes
  • All nox stages pass
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.4.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

## Background and Context The project's `CONTRIBUTING.md` strictly forbids the use of `# type: ignore` or any other mechanism to suppress type-checking errors. The rule states: > **No Type Ignores**: The use of `# type: ignore` or any other mechanism to suppress type-checking errors is strictly forbidden. Two files in `application/services/` contain `# type: ignore[arg-type]` comments that violate this policy. ## Current Behavior **File 1**: `src/cleveragents/application/services/decomposition_service.py`, line 79: ```python return max(counts, key=counts.get) # type: ignore[arg-type] ``` **File 2**: `src/cleveragents/application/services/decomposition_clustering.py`, line 204: ```python dominant = max(ext_counts, key=ext_counts.get, default="") # type: ignore[arg-type] ``` Both suppressions are for the same underlying issue: `dict.get` has a return type of `V | None` (where `V` is the value type), but `max()`'s `key` parameter expects a callable that returns a comparable type. Pyright flags this because `None` is not comparable. ## Expected Behavior The `# type: ignore` comments should be removed and the code should be refactored to be properly typed. For example: ```python # Option 1: Use a lambda with a default return max(counts, key=lambda k: counts.get(k) or 0) # Option 2: Use operator.itemgetter import operator return max(counts, key=operator.itemgetter) # Option 3: Use counts.__getitem__ directly (since all keys exist in the dict) return max(counts, key=counts.__getitem__) ``` ## Code Locations 1. `src/cleveragents/application/services/decomposition_service.py`, line 79 (in `_dominant_extension` function) 2. `src/cleveragents/application/services/decomposition_clustering.py`, line 204 (in `ClusteringStrategy.deterministic_sort` method) ## Steps to Reproduce ```bash grep -n "type: ignore" src/cleveragents/application/services/decomposition_service.py # Line 79: return max(counts, key=counts.get) # type: ignore[arg-type] grep -n "type: ignore" src/cleveragents/application/services/decomposition_clustering.py # Line 204: dominant = max(ext_counts, key=ext_counts.get, default="") # type: ignore[arg-type] ``` ## Metadata - **Branch**: `fix/decomposition-type-ignore` - **Commit Message**: `fix(decomposition): remove forbidden type: ignore suppressions` - **Milestone**: *(none — backlog)* - **Parent Epic**: #368 ## Subtasks - [ ] Fix `_dominant_extension` in `decomposition_service.py` to remove `# type: ignore` - [ ] Fix `deterministic_sort` in `decomposition_clustering.py` to remove `# type: ignore` - [ ] Run `nox -e typecheck` to verify pyright passes without suppressions - [ ] Run `nox` to verify all tests pass ## Definition of Done - [ ] No `# type: ignore` comments in either file - [ ] `nox -e typecheck` passes - [ ] `nox` passes - [ ] All nox stages pass - [ ] Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.4.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
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
#368 Epic: Subplans & Parallelism
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3754
No description provided.