BUG-HUNT: [type-safety] Unresolved import mcp_stub_server in m2_actor_tool_smoke_bench.py #3799

Open
opened 2026-04-06 06:25:17 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/type-safety/mcp-stub-server-import-bench
  • Commit Message: fix(benchmarks): resolve mcp_stub_server import via pyrightconfig extraPaths
  • Milestone: None (backlog — see note below)
  • Parent Epic: #2810

Bug Report: [type-safety] — Unresolved import mcp_stub_server in m2_actor_tool_smoke_bench.py

Severity Assessment

  • Impact: Medium. This construct breaks static analysis tooling and violates the project's strict type-checking standards. It makes the code harder to understand, maintain, and refactor.
  • Likelihood: High. The static analysis will always fail for this file.
  • Priority: Medium

Location

  • File: benchmarks/m2_actor_tool_smoke_bench.py
  • Lines: 24-26, 34

Description

The file benchmarks/m2_actor_tool_smoke_bench.py dynamically modifies sys.path to import the mcp_stub_server module from the features/mocks/ directory. While this might allow the code to run, it prevents static analysis tools like Pyright from resolving the import, leading to a type-checking error. The project's contribution guidelines state that all code must pass the Pyright type checker.

Evidence

# benchmarks/m2_actor_tool_smoke_bench.py:24-26
_MOCKS = str(Path(__file__).resolve().parents[1] / "features" / "mocks")
if _MOCKS not in sys.path:
    sys.path.insert(0, _MOCKS)

# benchmarks/m2_actor_tool_smoke_bench.py:34
from mcp_stub_server import McpStubServer  # noqa: E402

Pyright Error:

error: Import "mcp_stub_server" could not be resolved (reportMissingImports)

Expected Behavior

All imports should be resolvable by static analysis tools without resorting to dynamic modifications of sys.path. The code should adhere to the project's type-checking standards.

Actual Behavior

The use of sys.path.insert causes a type-checking error and makes the code less maintainable.

Suggested Fix

Instead of modifying sys.path, consider one of the following solutions:

  1. Configure Pyright's extraPaths: Add the features/mocks directory to the extraPaths in the pyrightconfig.json file. This will allow Pyright to find the module.
  2. Make mocks a package: Add an __init__.py file to the features/mocks directory and use a relative import.

Category

type-safety

Subtasks

  • Investigate the root cause: confirm Pyright cannot resolve mcp_stub_server due to sys.path manipulation
  • Choose the appropriate fix: add features/mocks to extraPaths in pyrightconfig.json OR restructure features/mocks as a proper package
  • Remove the sys.path.insert block (lines 24-26) from benchmarks/m2_actor_tool_smoke_bench.py
  • Update the import on line 34 to use the resolved path (if restructuring as a package)
  • Verify nox -e typecheck passes with zero Pyright errors on the affected file
  • Verify nox -e unit_tests and benchmarks still pass with no regressions
  • Verify coverage remains >= 97% (nox -e coverage_report)

Definition of Done

  • benchmarks/m2_actor_tool_smoke_bench.py no longer uses sys.path.insert to resolve mcp_stub_server
  • mcp_stub_server import is fully resolvable by Pyright without errors
  • nox -e typecheck passes with no Pyright errors on the affected file
  • No new type suppressions (# type: ignore) introduced 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: Bug Hunting | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/type-safety/mcp-stub-server-import-bench` - **Commit Message**: `fix(benchmarks): resolve mcp_stub_server import via pyrightconfig extraPaths` - **Milestone**: None (backlog — see note below) - **Parent Epic**: #2810 ## Bug Report: [type-safety] — Unresolved import mcp_stub_server in m2_actor_tool_smoke_bench.py ### Severity Assessment - **Impact**: Medium. This construct breaks static analysis tooling and violates the project's strict type-checking standards. It makes the code harder to understand, maintain, and refactor. - **Likelihood**: High. The static analysis will always fail for this file. - **Priority**: Medium ### Location - **File**: `benchmarks/m2_actor_tool_smoke_bench.py` - **Lines**: 24-26, 34 ### Description The file `benchmarks/m2_actor_tool_smoke_bench.py` dynamically modifies `sys.path` to import the `mcp_stub_server` module from the `features/mocks/` directory. While this might allow the code to run, it prevents static analysis tools like Pyright from resolving the import, leading to a type-checking error. The project's contribution guidelines state that all code must pass the Pyright type checker. ### Evidence ```python # benchmarks/m2_actor_tool_smoke_bench.py:24-26 _MOCKS = str(Path(__file__).resolve().parents[1] / "features" / "mocks") if _MOCKS not in sys.path: sys.path.insert(0, _MOCKS) # benchmarks/m2_actor_tool_smoke_bench.py:34 from mcp_stub_server import McpStubServer # noqa: E402 ``` **Pyright Error:** ``` error: Import "mcp_stub_server" could not be resolved (reportMissingImports) ``` ### Expected Behavior All imports should be resolvable by static analysis tools without resorting to dynamic modifications of `sys.path`. The code should adhere to the project's type-checking standards. ### Actual Behavior The use of `sys.path.insert` causes a type-checking error and makes the code less maintainable. ### Suggested Fix Instead of modifying `sys.path`, consider one of the following solutions: 1. **Configure Pyright's `extraPaths`**: Add the `features/mocks` directory to the `extraPaths` in the `pyrightconfig.json` file. This will allow Pyright to find the module. 2. **Make `mocks` a package**: Add an `__init__.py` file to the `features/mocks` directory and use a relative import. ### Category type-safety ## Subtasks - [ ] Investigate the root cause: confirm Pyright cannot resolve `mcp_stub_server` due to `sys.path` manipulation - [ ] Choose the appropriate fix: add `features/mocks` to `extraPaths` in `pyrightconfig.json` OR restructure `features/mocks` as a proper package - [ ] Remove the `sys.path.insert` block (lines 24-26) from `benchmarks/m2_actor_tool_smoke_bench.py` - [ ] Update the import on line 34 to use the resolved path (if restructuring as a package) - [ ] Verify `nox -e typecheck` passes with zero Pyright errors on the affected file - [ ] Verify `nox -e unit_tests` and benchmarks still pass with no regressions - [ ] Verify coverage remains >= 97% (`nox -e coverage_report`) ## Definition of Done - [ ] `benchmarks/m2_actor_tool_smoke_bench.py` no longer uses `sys.path.insert` to resolve `mcp_stub_server` - [ ] `mcp_stub_server` import is fully resolvable by Pyright without errors - [ ] `nox -e typecheck` passes with no Pyright errors on the affected file - [ ] No new type suppressions (`# type: ignore`) introduced 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: Bug Hunting | 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.

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