Repository navigation
feat: add pyright script for type checking with configuration - #1123
JithinBathula wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5842d1e6dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 16c3f4e261
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| elif command -v uvx >/dev/null 2>&1; then | ||
| PYRIGHT_CMD_ARR=(uvx --from pyright pyright) | ||
| elif command -v npx >/dev/null 2>&1; then | ||
| PYRIGHT_CMD_ARR=(npx pyright) |
There was a problem hiding this comment.
Fall through to next backend when uvx invocation fails
Selecting the backend solely by command -v means the script commits to uvx whenever it is installed, and with set -e it exits on the first uvx failure without ever trying npx. This breaks type-check runs in environments where uvx is present but cannot execute pyright (for example, restricted package access) while npx pyright is still usable, so the intended fallback chain is not actually resilient.
Useful? React with 👍 / 👎.
|
The autocomment on flipping precedence order seems right, it'd match the other shell scripts here. Can you change? Thanks! |
lmeyerov
left a comment
There was a problem hiding this comment.
Thanks! See #1123 (comment) and then we can merge
|
@codex I agree with your review below, please address
|
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex address that feedback |
|
To use Codex here, create an environment for this repo. |
|
Updated the script based on the comment. Thanks |
* ci(pyright): gate on the rules a file decides for itself Pyright catches what ruff and mypy miss: locals bound on only some paths, names that resolve nowhere, statements with no effect. Running it is easy; gating on it is not, because most of its rules read third-party stubs. Measured over five environments (python 3.8/3.11/3.12/3.14, and a workstation carrying polars, cudf, scipy and scikit-learn) on one unchanged tree, reportAttributeAccessIssue ranges from 146 to 810 findings, reportReturnType from 2 to 78. A gate on those fails for whoever has cudf installed and passes in CI. So only five rules gate -- the ones decided by a file's own control flow, names and syntax -- and the rest are reported but never enforced. Agreement across environments was necessary but not sufficient evidence: reportOptionalSubscript, reportTypedDictNotRequiredAccess and reportIndexIssue all matched across four environments and then diverged on the fifth, being rare enough to agree by luck. The admission bar is the principle, not the sample. - bin/pyright.sh pins pyright 1.1.414, and uses a local install only when it is that version; an unpinned tool moves the baseline underneath us. - bin/ci_pyright_guard.py ratchets per-file counts against bin/ci_pyright_baseline.json, the same shape as the type-hygiene and comment-density guards: counts may shrink, never grow, and a file absent from the baseline must be clean. - python-pyright runs it on py3.12 only. All seven lint matrix cells would produce byte-identical output for these rules. 273 findings are grandfathered. 195 of them are one module that builds its namespace with globals().update(vars(...)) and already carries `# mypy: ignore-errors` and `# ruff: noqa: F821`; its count is left visible rather than excluded so that fixing it shows up as slack under --strict. Builds on #1123 by Jithin Bathula, whose bin/pyright.sh and pyrightconfig.json this keeps. Closes #1075. Co-Authored-By: Jithin Bathula <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017ropeBMLJUuy6ViYwy15ud * ci(pyright): fail on a collapsed gate and on files that do not parse Review of the previous commit found the ratchet could go quiet without anyone noticing, which defeats its purpose. Scope lives in pyrightconfig.json, a different file from the baseline, so widening an exclude silenced the gate with no baseline change and no failure: appending "graphistry/compute" to exclude dropped the gated findings from 273 to 56 and still exited 0 -- while printing "10 file(s) now below baseline". The guard observed the collapse and passed anyway. Shrinking findings and shrinking scope are indistinguishable from counts alone, so the baseline now records the file count it was built over and a run that sees materially less fails. A real scope change is still fine; it just has to go through --update-baseline, where the delta shows up in review. Pyright reports a file it cannot parse with no rule at all, so those findings were routed to the ungated pile and could never fail. An unparseable file also yields fewer gated findings, so it read as an improvement. Parse failures consult no type either, so they are gated under <unparseable> and must stay at zero; the tree has none today. Also aligns Finding with the sibling guard's `@dataclass(frozen=True)` and real annotations rather than a hand-rolled __slots__ class and `# type:` comments. Verified: exclude-widening and a fabricated zero-file report now exit 1; an unparseable file exits 1 naming it; the injected possibly-unbound local still exits 1 and reverts to 0; one baseline still passes in all five environments. 19 tests, 13-mutant battery -- 12 caught, the 2 survivors inert alone and caught in combination. Co-Authored-By: Jithin Bathula <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017ropeBMLJUuy6ViYwy15ud * docs(develop): trim the pyright ratchet section to the size of its siblings 63 lines re-derived the environment measurement in prose; that argument lives in the PR and does not need repeating for someone reaching for the commands. 42 lines now, next to Type Hygiene at 39 and Comment Density at 43. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017ropeBMLJUuy6ViYwy15ud --------- Co-authored-by: Jithin Bathula <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
|
Thank you for this, @JithinBathula — and apologies it sat open so long. Your work has landed. Two things had to be settled before it could gate, both of which you'd flagged as non-goals: The tool needed pinning. The version is now fixed at The rules needed sorting by whether they're reproducible. Running your config across five environments (python 3.8/3.11/3.12/3.14, and a workstation with polars + cudf + scipy + scikit-learn) showed most pyright rules move with the environment: It's now a real CI job ( And it found real bugs. The
The ratchet went from 273 findings to 230 across that series. It started with your PR. Closing this one as superseded, not rejected — the code is in |
|
Superseded by #2092, which carries this work with attribution. See the comment above for where each piece landed. |
Summary
Adds pyright configuration and local runner script to catch conditionally-assigned variable bugs (like edge_map at hop.py:974) that ruff and mypy miss. No code changes — tooling only.
Non-goals: CI integration, code fixes, rule enforcement — all follow-up PRs.
Validation
bin/pyright.sh graphistry/compute/hop.pyconfirmshop.py:974:122 - warning: "edge_map" is possibly unboundCypher Frontend CI Evidence (when PR touches cypher frontend / IR scope)
cypher-frontend-strict-typing (py3.12)passed (strict typing gate)cypher-frontend-differential-parity (py3.12)passed (trust-but-verify gate)cypher-frontend-ci-gatespassed (includestest-minimal-pythonsentinel)