Support Ruff 0.16 suppression directives - #12
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Included review availability: 2 reviews are currently available. Based on recent review activity, included reviews refill at 3 per hour. SummaryExtend
Validate formatting, linting, type checking, tests, auditing, Markdown, Mermaid, and Makefile checks. The suite passes 322 tests, with one skipped test. WalkthroughUpdate suppression parsing for Ruff directives and rule-list formats. Require preceding explanations to contain prose beyond directives. Document and test the syntax, standalone-comment rules, and neutral behaviour of ChangesSuppression validation
Possibly related PRs
Poem
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 warning, 4 inconclusive)
✅ Passed checks (15 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Require explanations for Ruff line, file, and range suppression directives, including rule-name selectors and the documented spacing and trailing-comma variants. Keep range terminators neutral, extend regression coverage for the full comment grammar, document the expanded rule, and lock Ruff 0.16.0 so the compatibility contract is exercised by the project gates.
Recognize Ruff suppression and range directives when whitespace separates the keyword from its selector bracket. Keep spaced `enable` terminators neutral so they cannot explain a following suppression accidentally. Add regressions for line-level, file-level and range forms accepted by Ruff 0.16.0.
Describe Ruff range terminators and the complete suppression grammar in the user and developer guides. Add generated coverage for grammar variants, explanation precedence, and neutral enable directives.
Treat Ruff directives as case-sensitive and require file-level and range directives to occupy standalone comments. Avoid C9106 false positives for forms that Ruff itself does not recognize as suppressions.
Recognize range terminators even when trailing prose follows them. Prevent the entire comment from explaining a later suppression and add a regression that distinguishes neutral handling from ignoring `enable` altogether.
Require complete selector lists before classifying Ruff suppressions, and cover malformed, case-invalid, and misplaced forms. Move the generated suppression properties into their own module so the rebased suite remains within the project's file-size limit.
b37a9fc to
29c3639
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai Have the following now been resolved? docs/users-guide.md (1)
not emit C9106, which contradicts Lines 144-146. 🤖 Detailed instructionsVerify each finding against current code. Fix only still-valid issues, skip the In docs/developers-guide.md (1)
🤖 Detailed instructionsVerify each finding against current code. Fix only still-valid issues, skip the In |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- docs/users-guide.md: relevant lines ---'
nl -ba docs/users-guide.md | sed -n '125,155p'
printf '%s\n' '--- docs/developers-guide.md: relevant lines ---'
nl -ba docs/developers-guide.md | sed -n '30,60p'
printf '%s\n' '--- directive parsing implementation ---'
ast-grep outline df12_python_lints/suppressions.py --items all --view expanded
rg -n -C 5 -P 'ruff:|flake8:|noqa|_directive_symbols|is_standalone' df12_python_lints/suppressions.pyLength of output: 919 🏁 Script executed: #!/bin/bash
set -euo pipefail
show_lines() {
file="$1"
start="$2"
end="$3"
printf '%s\n' "--- ${file}:${start}-${end} ---"
sed -n "${start},${end}p" "$file" | awk -v n="$start" '{ printf "%d: %s\n", n++, $0 }'
}
show_lines docs/users-guide.md 125 155
show_lines docs/developers-guide.md 30 60
printf '%s\n' '--- matching implementation locations ---'
grep -n -E -C 5 'ruff:|flake8:|noqa|_directive_symbols|is_standalone' df12_python_lints/suppressions.py || true
printf '%s\n' '--- implementation context ---'
grep -n -E '_directive_symbols|RUFF|NOQA|FLAKE8' df12_python_lints/suppressions.py || trueLength of output: 10193 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- suppression documentation in both guides ---'
grep -n -i -E -C 4 'ruff:[[:space:]]*noqa|flake8:[[:space:]]*noqa|standalone comment|case-sensitive|case-insensitive|suppression' \
docs/users-guide.md docs/developers-guide.md || true
printf '%s\n' '--- alias-related tests ---'
grep -n -i -E -C 4 'ruff:[[:space:]]*noqa|flake8:[[:space:]]*noqa|standalone|case-sensitive|case-insensitive' \
tests/test_suppressions.py tests/test_suppression_properties.py 2>/dev/null || true
printf '%s\n' '--- regex behaviour for requested alias forms ---'
python - <<'PY'
from df12_python_lints import suppressions
cases = (
("# ruff: noqa", True),
("# Ruff: noqa", True),
("value = 1 # ruff: noqa", False),
("# flake8: noqa", True),
("# Flake8: noqa", True),
("value = 1 # flake8: noqa", False),
("value = 1 # NOQA", False),
)
for text, standalone in cases:
comment = suppressions._Comment(text, standalone)
print(f"{text!r}, standalone={standalone}: {suppressions._directive_symbols(comment)!r}")
PYLength of output: 14127
Mark the
Keep the file-level
The current checker emits C9106 for all of these forms: # Ruff: noqa
value = 1 # ruff: noqa
# Flake8: noqa
value = 1 # flake8: noqaUpdate the parser and add regression tests to enforce the documented standalone and case-sensitive alias rules. Alternatively, revise both guides to describe the current behaviour. 🧠 Learnings usedYou are interacting with an AI system. |
|
@coderabbitai Have the following now been resolved? df12_python_lints/suppressions.py (1)
🤖 Detailed instructionsUse a wyvern agent team to verify each finding against the current code and only fix it if needed. Fix any documentation issues using a scribe agent team. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Use a scrutineer agent for execution of tests and summarizing the results. In |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- PR head and changed files ---'
git status --short
git diff --name-only HEAD^ HEAD || true
printf '%s\n' '--- suppressions module outline ---'
ast-grep outline df12_python_lints/suppressions.py --items all --view expanded
printf '%s\n' '--- directive parsing implementation ---'
nl -ba df12_python_lints/suppressions.py | sed -n '35,115p'
printf '%s\n' '--- Ruff-related regression tests ---'
rg -n -i -C 5 'ruff|file-ignore|disable|standalone|case-sensitive|invalid' \
tests/test_suppressions.py tests/test_suppression_properties.py 2>/dev/null || true
printf '%s\n' '--- relevant PR diff ---'
git diff HEAD^ HEAD -- df12_python_lints/suppressions.py tests/test_suppressions.py tests/test_suppression_properties.py || trueLength of output: 2701 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- parser patterns and classification ---'
sed -n '45,140p' df12_python_lints/suppressions.py
printf '%s\n' '--- standalone comment collection ---'
sed -n '160,225p' df12_python_lints/suppressions.py
printf '%s\n' '--- exact negative Ruff regressions ---'
rg -n -C 6 -e 'RUFF:' -e 'ruff: file-ignore' -e 'ruff: disable' \
tests/test_suppressions.py tests/test_suppression_properties.py 2>/dev/null || true
printf '%s\n' '--- test classes and nearby Ruff cases ---'
ast-grep outline tests/test_suppressions.py --items all --view expanded
rg -n -C 4 -i 'invalid.*ruff|ruff.*invalid|standalone.*ruff|ruff.*standalone' \
tests/test_suppressions.py tests/test_suppression_properties.py 2>/dev/null || trueLength of output: 14300
The test suite was not executed in this sandbox. Static inspection confirms that the implementation and regression tests meet the finding requirements. You are interacting with an AI system. |
Document the v0.3.0 suppression-comment requirements so projects can update newly recognised Ruff and Flake8 pragmas without losing their rationale. Explain accepted syntax and the neutral `ruff: enable[...]` range terminator.
Summary
This branch extends
lint-suppression-without-explanationto recognize Ruff0.16 line-level, file-level, and range suppression directives, so diagnostic
suppression continues to carry an auditable reason. It locks Ruff 0.16.0 to
exercise that compatibility contract in repository gates.
The parser accepts rule codes and preview rule names, documented whitespace
(including before selector brackets), and trailing commas. It requires a
complete selector list, rejects case-invalid and misplaced forms, and matches
Ruff directives case-sensitively. File-level and range directives must occupy
standalone comments.
ruff: enable[...]ends a suppression range, so itneither requires a reason nor counts as prose explaining a later directive.
The user and developer guides record the grammar, aliases, and explanation
precedence. The v0.3.0 migration guide shows maintainers how to update newly
flagged directives. Hypothesis properties generate directive kinds, selectors,
whitespace, separators, trailing commas, explanation placements, and neutral
range terminators. The property suite has its own module to keep test files
within the repository's file-size limit.
Review walkthrough
suppressions.pyfor syntax-specific directive detection and explanation classification.test_suppressions.pyfor valid directives and malformed, case-invalid, and misplaced regressions.test_suppression_properties.pyfor generated grammar and explanation-precedence coverage.users-guide.mdanddevelopers-guide.mdfor public and internal checker contracts.migration-0.3.0.mdfor upgrade steps covering directives, explanations, and range terminators.uv.lockfor the focused Ruff 0.16.0 update.Validation
make check-fmt: passed.make test: passed; 322 passed, 1 skipped.make typecheck: passed.make lint: passed; Ruff, 100% interrogate coverage and PyPy-backed Pylint (10.00/10) were clean.make audit: passed with no known vulnerabilities.make markdownlint: passed, including the en-GB-oxendict spelling gate.make nixie: passed; all Mermaid diagrams validated.mbake validate Makefile: passed.References