Skip to content

ci: type-check every supported platform, and fix what that surfaced - #1301

Open
itzzdev09 wants to merge 1 commit into
usestrix:mainfrom
itzzdev09:ci/typecheck-all-platforms
Open

ci: type-check every supported platform, and fix what that surfaced#1301
itzzdev09 wants to merge 1 commit into
usestrix:mainfrom
itzzdev09:ci/typecheck-all-platforms

Conversation

@itzzdev09

Copy link
Copy Markdown
Contributor

Follow-up to the review discussion on #1297, where a reviewer pointed out that platform-specific branches were not being type-checked. They were right about the gap, though not about the cause — so here is the real fix.

The gap

I assumed CI ran mypy on Linux. It doesn't run mypy at allbuild-release.yml only builds release artifacts on tags. Type checking happens through make type-check and the pre-commit hook, both of which use whichever platform the contributor is on.

Two consequences:

  1. Nothing gates a merge on type checking.
  2. sys.platform == "win32" branches are never checked by anyone, because almost no one develops on Windows — while a contributor who does sees six errors nobody else has.

Measured on main, same interpreter, same source:

--platform errors
linux 0
darwin 0
win32 6

The six: fcntl.flock / LOCK_EX / LOCK_UN (×4) in config/codex.py, and os.getuid / os.getgid (×2) in runtime/session_manager.py.

The change

A Type check workflow running mypy under --platform linux, darwin, and win32 on pull requests and pushes to main.

All three jobs run on ubuntu-latest. --platform is what selects which branches mypy resolves, so three runner OSes would cost three times as much and each would still check whatever platform it happened to be. Actions are SHA-pinned with version comments and persist-credentials: false, matching build-release.yml.

Making --platform win32 pass, which needed the two platform-specific spots to resolve under every target:

  • codex.py called fcntl.flock directly. It is now resolved once behind a sys.platform != "win32" guard with a no-op fallback. Runtime behaviour is unchanged: the ImportError branch it previously relied on could only ever fire on Windows, which the guard now expresses explicitly rather than discovering at import time.
  • session_manager.py called os.getuid / os.getgid. The existing Linux check is now wrapped in a platform guard so the attributes resolve, keeping the indirection through a local variable that the original comment explains.

# type: ignore[attr-defined] was not available here — warn_unused_ignores = true would then flag it as unused on the platforms where the attribute does exist. The guard form works because mypy exempts platform-guarded blocks from warn_unreachable, which I verified before writing it.

make type-check now runs the same three platforms as CI, so local and CI agree.

Result

--platform before after
linux 0 0
darwin 0 0
win32 6 0

ruff and ruff format clean on both touched files. tests/test_codex_auth.py, test_codex_streaming.py, test_local_sources.py, and test_runner_teardown.py all pass.

Bearing on #1297

#1297 sets platform = "linux" in [tool.mypy]. That was a workaround for exactly these six errors, and the reviewer was right to push back on it. This PR removes the need for it, so I've dropped that line from #1297 — the two no longer overlap and can merge in either order.

Scope

Deliberately narrow: type checking only. Adding test and lint jobs is #1260, which is a larger conversation about what should gate a merge, and I'd rather not fold it into this.

🤖 Generated with Claude Code

`make type-check` ran mypy for whichever platform the developer happened
to be on, and no workflow ran it at all, so nothing gated a merge on it.
The practical effect was that `sys.platform == "win32"` branches were
never type-checked by anyone, while a Windows contributor saw six errors
that did not exist for anyone else.

Add a workflow running mypy under --platform linux, darwin and win32.
All three run on Linux because --platform is what selects the branches
mypy resolves; three runner OSes would cost three times as much and each
would still check whatever platform it happened to be.

Making --platform win32 pass needed the two platform-specific spots to
resolve under every target:

- codex.py reached fcntl.flock directly, which does not exist on
  Windows. Resolve it once behind a `sys.platform != "win32"` guard,
  which mypy narrows under every --platform, with a no-op fallback.
  Behaviour is unchanged: the ImportError path it used to rely on only
  ever fired on Windows, which the guard now covers explicitly.
- session_manager.py reached os.getuid/os.getgid. Wrap the existing
  Linux check in a platform guard so the attributes resolve, keeping the
  indirection through a local that the original comment explains.

`# type: ignore[attr-defined]` was not an option: warn_unused_ignores
would then flag it on the platforms where the attribute does exist.

`make type-check` now runs the same three platforms as CI.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
itzzdev09 added a commit to itzzdev09/strix that referenced this pull request Sep 12, 2026
`platform = "linux"` was a workaround for six Windows-only attribute
errors on `fcntl` and `os.getuid`. Review pushed back, correctly: it
makes local runs deterministic but checks no platform-specific branch
under its own platform.

usestrix#1301 fixes those six at the source and adds a workflow running mypy
under --platform linux, darwin and win32, so the pin is no longer
needed. Removing it here leaves this PR scoped to test assumptions and
lets the two merge in either order.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The implementation appears safe to merge, with the non-blocking caveat that CI still does not enforce pyright as required by the repository’s full local type-check contract.

Findings

  1. P2 Pyright Is Not Gated
Fix with agent prompt
### Issue 1
.github/workflows/typecheck.yml:42-43
This workflow runs only mypy, but the repository defines `make type-check` as running both mypy and pyright, and `make check-all` requires that full target. No other pull-request workflow or pre-commit hook runs pyright, so a pyright-only error can pass CI even though the documented local check fails. Please add a pyright step or run the full type-check target after the platform-specific mypy jobs.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

  • Runs three mypy platform targets on an Ubuntu runner.
  • Resolves POSIX file-lock operations behind an explicit platform boundary.
  • Guards Linux host UID/GID collection from Windows type resolution.
  • The CI workflow does not yet enforce the pyright portion of the repository’s local type-check contract.

Reviews (1) · Last reviewed commit: "ci: type-check every supported platform,..."

Comment on lines +42 to +43
- name: mypy --platform ${{ matrix.platform }}
run: uv run mypy --platform ${{ matrix.platform }} strix/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Pyright Is Not Gated

This workflow runs only mypy, but the repository defines make type-check as running both mypy and pyright, and make check-all requires that full target. No other pull-request workflow or pre-commit hook runs pyright, so a pyright-only error can pass CI even though the documented local check fails. Please add a pyright step or run the full type-check target after the platform-specific mypy jobs.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/typecheck.yml
Line: 42-43

Comment:
**Pyright Is Not Gated**

This workflow runs only mypy, but the repository defines `make type-check` as running both mypy and pyright, and `make check-all` requires that full target. No other pull-request workflow or pre-commit hook runs pyright, so a pyright-only error can pass CI even though the documented local check fails. Please add a pyright step or run the full type-check target after the platform-specific mypy jobs.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

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