Repository navigation
fix(ci): satisfy Circle strict mypy checks - #3077
Conversation
|
Warning Review limit reached
Next review available in: 37 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
) ## Summary The Nix devshell's `mypy` entry in `buildInputs` silently shadowed the uv.lock-pinned mypy 2.3.0 with the Nix store's 1.20.1, hiding real strict-mypy findings locally that CircleCI's bare-Docker quick-gate would catch. ## Problem `devShells.default.buildInputs` listed `mypy` directly (a Python library package). mkShell's Python setup hooks add such packages' site-packages to `PYTHONPATH`, and `PYTHONPATH` entries are consulted before a venv's own site-packages when Python builds `sys.path`. So `.venv/bin/mypy` (and any `uv run mypy`) ran the Nix-provided 1.20.1 instead of the correctly-installed 2.3.0 in `.venv`, even inside an activated devshell. This is exactly the class of drift PR #3077 hit and fixed for `polylogue/` on CircleCI: findings invisible locally, red on CI. Running the real 2.3.0 against the full `[tool.mypy] files` config (`polylogue`, `tests/**`, `devtools/**` — CircleCI checks `polylogue/` only) surfaced two further findings CI has never covered: - `tests/unit/coordination/test_envelope.py:215` — a real mypy narrowing limitation: after `key in {tuple_a, tuple_b, tuple_c}` narrows a tuple, mypy only tracks one alternative's literal type for a later subscript (`key[1]`), so a subsequent sibling `if key[1] == "gate":` is flagged as comparing non-overlapping literals even though the runtime behavior is correct. - `tests/unit/cost/test_contract_suite.py:203` — a tautological assertion (`!= "exact"`) already entailed by the preceding `in {"priced", "partial"}` check on the same narrowed value. ## Solution - Drop `mypy` from the devshell's `buildInputs`. `.venv` (via `uv sync --extra dev`) is already the sole mypy provider; the Nix copy served no purpose except colliding with it. - `test_envelope.py`: bind the tuple element to an explicit `str` local (`subcommand: str = key[1]`) before comparing, which stops mypy from carrying an overly narrow literal type across the two sibling checks. No runtime behavior change. - `test_contract_suite.py`: delete the redundant assertion; the preceding line already proves it. - `.gitignore`: add `.dmypy.json`, the dmypy daemon state file that a now-actually-working `dmypy` invocation creates at the repo root (alongside the existing `.mypy_cache/` entry). ## Verification - `nix develop --command bash -c 'python3 -c "import mypy; print(mypy.__file__, mypy.__version__)"'` → resolves to `.venv/.../mypy` at 2.3.0 (was the Nix store's 1.20.1 before this change). - `nix develop --command uv run mypy polylogue/` → clean (matches CircleCI, whose 3 original findings were already fixed by #3077). - `nix develop --command devtools verify --quick` → 17/17 steps green, `exit_code: 0`. - `devtools test tests/unit/coordination/test_envelope.py tests/unit/cost/test_contract_suite.py` → 40 passed. 1 pre-existing failure unrelated to this change (`KeyError: 'cost_outlook'` in `test_mcp_cost_outlook_tool_uses_shared_envelope`) reproduces identically with these edits stashed out — MCP six-tool-cutover registry drift from #3095, not touched by this PR. Ref polylogue-i0ep
Summary
Repair the three strict-mypy failures exposed by Circle after SQLite compatibility was restored.
Problem
Circle reached
mypyand reported two redundant casts plus an invalidselect.select()argument inference. These were hidden locally only until the CI environment exercised the updated source set.Solution
Use explicit literal narrowing for hook-provider and aggregate-sort paths, and narrow the socket-like HTTP connection before passing it to
select.Verification
uv run mypy polylogue/— passed.devtools verify --quick— passed before push; pre-push quick verification also passed.