Skip to content

Declare ruff's vendored-file excludes once in pyproject.toml - #9090

Open
hjmjohnson wants to merge 1 commit into
Project-MONAI:devfrom
BRAINSia:mono-ruff-extend-exclude
Open

Declare ruff's vendored-file excludes once in pyproject.toml#9090
hjmjohnson wants to merge 1 commit into
Project-MONAI:devfrom
BRAINSia:mono-ruff-extend-exclude

Conversation

@hjmjohnson

@hjmjohnson hjmjohnson commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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.

Verification
  • 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.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 788796ff-36ec-46f1-8037-0d10860c89c8

📥 Commits

Reviewing files that changed from the base of the PR and between 9ea04d4 and 02eb3d5.

📒 Files selected for processing (2)
  • pyproject.toml
  • runtests.sh

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

Ruff now excludes versioneer.py and monai/_version.py through the [tool.ruff] configuration. The runtests.sh Ruff commands no longer pass these exclusions directly.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to 02eb3

Ruff exclusions are centralized in the shared configuration while the test script removes duplicate flags, with no remaining merge-readiness risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: centralizing Ruff exclusions in pyproject.toml.
Description check ✅ Passed The description gives clear context, implementation details, scope, verification results, and related PR information. It does not reproduce the template headings or checklist, but it contains the requ…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description gives clear context, implementation details, scope, verification results, and related PR information. It does not reproduce the template headings or checklist, but it contains the required change description and verification context.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

versioneer.py and monai/_version.py were excluded from ruff twice,
independently: .pre-commit-config.yaml's ruff 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 (and any other caller that lets ruff discover its own
config) the same exclusion pre-commit's hook already applies, so the
CLI flags on the runtests.sh invocation are redundant and dropped.

Verified: 'ruff check' with pyproject.toml's new extend-exclude,
given the directory the way runtests.sh gives it, still reports
'All checks passed!' for the tree, and 'runtests.sh --ruff' is
unaffected end to end. Ruff ignores config exclude when handed
explicit filenames instead of a directory (the pre-commit hook path,
already governed by its own hook-level exclude, and not something
this PR touches).

Signed-off-by: Hans Johnson <hans-johnson@uiowa.edu>
@hjmjohnson
hjmjohnson force-pushed the mono-ruff-extend-exclude branch from 7839e1c to 02eb3d5 Compare September 3, 2026 15:12
@hjmjohnson
hjmjohnson marked this pull request as ready for review September 3, 2026 15:16
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