Skip to content

fix(ci): satisfy Circle strict mypy checks - #3077

Merged
Sinity merged 1 commit into
masterfrom
fix/ci/circle-mypy-strict
Jul 18, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/ci/circle-mypy-strict

Conversation

@Sinity

@Sinity Sinity commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Repair the three strict-mypy failures exposed by Circle after SQLite compatibility was restored.

Problem

Circle reached mypy and reported two redundant casts plus an invalid select.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

  • Circle raw job output identified all three failures.
  • uv run mypy polylogue/ — passed.
  • devtools verify --quick — passed before push; pre-push quick verification also passed.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2f16f82d-b689-4c85-8e3d-18c96d3a16b3

📥 Commits

Reviewing files that changed from the base of the PR and between bf8191b and 394dc0e.

📒 Files selected for processing (3)
  • polylogue/archive/query/unit_results.py
  • polylogue/daemon/http.py
  • polylogue/hooks/__init__.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ci/circle-mypy-strict

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity merged commit e3ed7ae into master Jul 18, 2026
3 checks passed
@Sinity
Sinity deleted the fix/ci/circle-mypy-strict branch July 18, 2026 01:07
Sinity added a commit that referenced this pull request Jul 18, 2026
)

## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant