ci: type-check every supported platform, and fix what that surfaced - #1301
Open
itzzdev09 wants to merge 1 commit into
Open
ci: type-check every supported platform, and fix what that surfaced#1301itzzdev09 wants to merge 1 commit into
itzzdev09 wants to merge 1 commit into
Conversation
`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>
Contributor
|
Comment on lines
+42
to
+43
| - name: mypy --platform ${{ matrix.platform }} | ||
| run: uv run mypy --platform ${{ matrix.platform }} strix/ |
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 all —
build-release.ymlonly builds release artifacts on tags. Type checking happens throughmake type-checkand the pre-commit hook, both of which use whichever platform the contributor is on.Two consequences:
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:--platformlinuxdarwinwin32The six:
fcntl.flock/LOCK_EX/LOCK_UN(×4) inconfig/codex.py, andos.getuid/os.getgid(×2) inruntime/session_manager.py.The change
A
Type checkworkflow running mypy under--platform linux,darwin, andwin32on pull requests and pushes tomain.All three jobs run on
ubuntu-latest.--platformis 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 andpersist-credentials: false, matchingbuild-release.yml.Making
--platform win32pass, which needed the two platform-specific spots to resolve under every target:codex.pycalledfcntl.flockdirectly. It is now resolved once behind asys.platform != "win32"guard with a no-op fallback. Runtime behaviour is unchanged: theImportErrorbranch it previously relied on could only ever fire on Windows, which the guard now expresses explicitly rather than discovering at import time.session_manager.pycalledos.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 = truewould then flag it as unused on the platforms where the attribute does exist. The guard form works because mypy exempts platform-guarded blocks fromwarn_unreachable, which I verified before writing it.make type-checknow runs the same three platforms as CI, so local and CI agree.Result
--platformlinuxdarwinwin32ruffandruff formatclean on both touched files.tests/test_codex_auth.py,test_codex_streaming.py,test_local_sources.py, andtest_runner_teardown.pyall 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