Skip to content

Commit 02eb3d5

Browse files
committed
ENH: Declare ruff's vendored-file excludes once in pyproject.toml
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>
1 parent 9ea04d4 commit 02eb3d5

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ exclude = '''
292292
[tool.ruff]
293293
line-length = 120
294294
target-version = "py310"
295+
# .pre-commit-config.yaml's ruff hook excludes these separately at the pre-commit layer
296+
extend-exclude = ["versioneer.py", "monai/_version.py"]
295297

296298
[tool.ruff.lint]
297299
select = [

runtests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,9 @@ then
599599

600600
if [ $doRuffFix = true ]
601601
then
602-
ruff check --fix --unsafe-fixes --exclude versioneer.py --exclude "monai/_version.py" "$homedir"
602+
ruff check --fix --unsafe-fixes "$homedir"
603603
else
604-
ruff check --exclude versioneer.py --exclude "monai/_version.py" "$homedir"
604+
ruff check "$homedir"
605605
fi
606606

607607
ruff_status=$?

0 commit comments

Comments
 (0)