Route runtests.sh ruff invocations through PY_EXE - #9089
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
Priority: ⬇️ Low — Defer this Ruff invocation fix because it is a narrow three-line test-script change with no broader product impact. Estimated code review effort: 1 (Trivial) | ~3 minutes Merge Risk: ⚪ Minimal · up to Ruff now runs from the selected Python environment, avoiding PATH-dependent failures while retaining existing lint options and behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description clearly explains the change, the failure scenario, and the expected behavior. It does not follow the repository template because it omits the issue reference, required section headings, and the types-of-changes checklist.
✨ 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 |
303842d to
2da2aed
Compare
runtests.sh calls every other formatter (black, isort, pylint, pytype)
via "${PY_EXE}" -m so it targets the same interpreter the
is_pip_installed() guard checked. The ruff invocations still called a
bare `ruff` off PATH, so is_pip_installed("ruff") could pass against
$PY_EXE while the invocation ran a different (or absent) ruff from
PATH. In a clean venv built per CONTRIBUTING.md with no editable
PATH entry, ./runtests.sh --codeformat fails with
"ruff: command not found" even though ruff is installed and
importable from $PY_EXE.
Reproduced: with $PY_EXE pointed at a venv holding ruff and that
venv absent from PATH, the old `ruff --version` failed with
"command not found"; "${PY_EXE}" -m ruff --version succeeded.
Signed-off-by: Hans Johnson <hans-johnson@uiowa.edu>
2da2aed to
e213eae
Compare
`versioneer.py` and `monai/_version.py` were excluded from ruff twice, independently: `.pre-commit-config.yaml`'s hook via its own `exclude:` regex, and `runtests.sh` via hardcoded `--exclude` flags on the CLI invocation. Neither read from `pyproject.toml`, so a third direct `ruff check` invocation — an editor, a one-off shell command — would lint and offer to rewrite both files: 200 violations today. `extend-exclude` in `[tool.ruff]` gives `runtests.sh`'s directory-walk invocation the same exclusion pre-commit's hook already applies, so the CLI flags there are now redundant and dropped. Independent of #9089 (which routes the same block's `ruff` calls through `PY_EXE`) — rebuilt directly off `dev` so the two PRs' diffs don't overlap. Whichever lands first, the other needs a small rebase over the same lines; neither depends on the other's content. <details> <summary>Verification</summary> - `ruff check` given the directory the way `runtests.sh` gives it (not explicit filenames) reports `All checks passed!` for the tree with the new `extend-exclude` in place, and `runtests.sh --ruff` is unaffected end to end. - Confirmed the CLI `--exclude` flag being dropped was purely additive over `extend-exclude`, not required for it to take effect: a synthetic `pyproject.toml` with only `extend-exclude` set already hid the excluded file from `ruff check .`, before any `--exclude` flag was added. - Ruff ignores config `exclude`/`extend-exclude` when handed explicit filenames instead of a directory — that's the pre-commit hook's path, already governed by its own hook-level `exclude:`, and this PR doesn't touch it. </details> <!-- provenance: claude-code session 2026-09-03, branch mono-ruff-extend-exclude off dev @ 9ea04d4 (rebuilt disjoint from #9089 per user request; previously stacked on that branch) related: split out of #9067 (closed) as one of three narrower follow-ups. Sibling: #9089 (independent, same file region), and #9091 (independent, version-pin cross-reference comments). --> Signed-off-by: Hans Johnson <hans-johnson@uiowa.edu> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
runtests.shcalls every other formatter (black, isort, pylint, pytype) through"${PY_EXE}" -m; the ruff invocations still called a bareruffoffPATH.is_pip_installed ruffchecks$PY_EXE, so the guard and the invocation could disagree — in a clean venv built perCONTRIBUTING.mdwith no editablePATHentry,./runtests.sh --codeformatfails withruff: command not foundeven though ruff is installed and importable from$PY_EXE.No behavior change when
ruffhappens to already be onPATH(the common case in an activated venv); this only fixes the case where it isn't.Reproduced before/after
With
$PY_EXEpointed at a venv holding ruff, and that venv absent fromPATH:./runtests.sh --ruffwith$PY_EXEset and the venv not onPATHnow reachesAll checks passed!instead of failing at the version check.