features/environment.py uses forbidden type: ignore comments in _install_fast_sleep_patch and _install_template_db_patch #8399

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

Metadata

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

Background and Context

The project's code quality standards (CONTRIBUTING.md) explicitly forbid type: ignore comments throughout the codebase. The standard states: "Type annotations everywhere (type: ignore is FORBIDDEN)."

At SHA 5a9aaa79edaefb1a257114f054ea87facb8efe69, features/environment.py contains multiple # type: ignore usages in two functions:

_install_fast_sleep_patch (lines ~180–200):

time._original_sleep = time.sleep  # type: ignore[attr-defined]
time.sleep = _capped_sleep  # type: ignore[assignment]
asyncio._original_sleep = asyncio.sleep  # type: ignore[attr-defined]
asyncio.sleep = _capped_async_sleep  # type: ignore[assignment]

_install_template_db_patch (line ~260):

MigrationRunner.init_or_upgrade = _fast_init_or_upgrade  # type: ignore[assignment]

These suppressions exist because the code monkey-patches standard library modules and a production class at runtime, which Pyright correctly flags as type errors. However, using type: ignore to silence these is forbidden by the project standard.

Current Behavior

features/environment.py contains 5 # type: ignore comments:

  1. time._original_sleep = time.sleep # type: ignore[attr-defined]
  2. time.sleep = _capped_sleep # type: ignore[assignment]
  3. asyncio._original_sleep = asyncio.sleep # type: ignore[attr-defined]
  4. asyncio.sleep = _capped_async_sleep # type: ignore[assignment]
  5. MigrationRunner.init_or_upgrade = _fast_init_or_upgrade # type: ignore[assignment]

Expected Behavior

Per CONTRIBUTING.md, type: ignore is FORBIDDEN. The code must be refactored to avoid these suppressions. Acceptable approaches include:

  1. Use cast() with proper type annotations instead of direct attribute assignment
  2. Use setattr() with a comment explaining the dynamic patching (avoids the type error without suppressing it)
  3. Use typing.TYPE_CHECKING guards where appropriate
  4. Introduce properly-typed wrapper protocols for the patched objects

Acceptance Criteria

  • features/environment.py contains zero # type: ignore comments
  • _install_fast_sleep_patch patches time.sleep and asyncio.sleep without type: ignore
  • _install_template_db_patch patches MigrationRunner.init_or_upgrade without type: ignore
  • Pyright/mypy passes on features/environment.py with no suppressed errors
  • All existing BDD tests continue to pass after the refactor

Subtasks

  • Refactor _install_fast_sleep_patch to eliminate # type: ignore[attr-defined] on time._original_sleep and asyncio._original_sleep
  • Refactor _install_fast_sleep_patch to eliminate # type: ignore[assignment] on time.sleep and asyncio.sleep
  • Refactor _install_template_db_patch to eliminate # type: ignore[assignment] on MigrationRunner.init_or_upgrade
  • Run nox -s typecheck to confirm zero type errors in features/environment.py
  • Run full BDD suite to confirm no regressions

Definition of Done

This issue is closed when features/environment.py contains zero # type: ignore comments and the typecheck nox session passes without errors on this file.


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

## Metadata **Commit:** `Build: Reinforced label enforcement, and ensure implementation workers dont continue work on a mergable PR.` **Branch:** main ## Background and Context The project's code quality standards (CONTRIBUTING.md) explicitly forbid `type: ignore` comments throughout the codebase. The standard states: "Type annotations everywhere (type: ignore is FORBIDDEN)." At SHA `5a9aaa79edaefb1a257114f054ea87facb8efe69`, `features/environment.py` contains multiple `# type: ignore` usages in two functions: **`_install_fast_sleep_patch` (lines ~180–200):** ```python time._original_sleep = time.sleep # type: ignore[attr-defined] time.sleep = _capped_sleep # type: ignore[assignment] asyncio._original_sleep = asyncio.sleep # type: ignore[attr-defined] asyncio.sleep = _capped_async_sleep # type: ignore[assignment] ``` **`_install_template_db_patch` (line ~260):** ```python MigrationRunner.init_or_upgrade = _fast_init_or_upgrade # type: ignore[assignment] ``` These suppressions exist because the code monkey-patches standard library modules and a production class at runtime, which Pyright correctly flags as type errors. However, using `type: ignore` to silence these is forbidden by the project standard. ## Current Behavior `features/environment.py` contains 5 `# type: ignore` comments: 1. `time._original_sleep = time.sleep # type: ignore[attr-defined]` 2. `time.sleep = _capped_sleep # type: ignore[assignment]` 3. `asyncio._original_sleep = asyncio.sleep # type: ignore[attr-defined]` 4. `asyncio.sleep = _capped_async_sleep # type: ignore[assignment]` 5. `MigrationRunner.init_or_upgrade = _fast_init_or_upgrade # type: ignore[assignment]` ## Expected Behavior Per CONTRIBUTING.md, `type: ignore` is FORBIDDEN. The code must be refactored to avoid these suppressions. Acceptable approaches include: 1. Use `cast()` with proper type annotations instead of direct attribute assignment 2. Use `setattr()` with a comment explaining the dynamic patching (avoids the type error without suppressing it) 3. Use `typing.TYPE_CHECKING` guards where appropriate 4. Introduce properly-typed wrapper protocols for the patched objects ## Acceptance Criteria - [ ] `features/environment.py` contains zero `# type: ignore` comments - [ ] `_install_fast_sleep_patch` patches `time.sleep` and `asyncio.sleep` without `type: ignore` - [ ] `_install_template_db_patch` patches `MigrationRunner.init_or_upgrade` without `type: ignore` - [ ] Pyright/mypy passes on `features/environment.py` with no suppressed errors - [ ] All existing BDD tests continue to pass after the refactor ## Subtasks - [ ] Refactor `_install_fast_sleep_patch` to eliminate `# type: ignore[attr-defined]` on `time._original_sleep` and `asyncio._original_sleep` - [ ] Refactor `_install_fast_sleep_patch` to eliminate `# type: ignore[assignment]` on `time.sleep` and `asyncio.sleep` - [ ] Refactor `_install_template_db_patch` to eliminate `# type: ignore[assignment]` on `MigrationRunner.init_or_upgrade` - [ ] Run `nox -s typecheck` to confirm zero type errors in `features/environment.py` - [ ] Run full BDD suite to confirm no regressions ## Definition of Done This issue is closed when `features/environment.py` contains zero `# type: ignore` comments and the typecheck nox session passes without errors on this file. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor
HAL9000 added this to the v3.3.0 milestone 2026-04-13 18:51:59 +00:00
Author
Owner

Verifiedtype: ignore comments in environment.py violate project architecture rules. MoSCoW: Must Have for v3.3.0 — architecture compliance applies to test infrastructure too. [AUTO-OWNR-1]


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

✅ **Verified** — `type: ignore` comments in environment.py violate project architecture rules. **MoSCoW: Must Have** for v3.3.0 — architecture compliance applies to test infrastructure too. [AUTO-OWNR-1] --- **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#8399
No description provided.