Skip to content

Exempt a PEP 723 Script Metadata Block From the Comment Rules - #3674

Merged
ptr727 merged 4 commits into
developfrom
fix/3634-pep723-comment-exempt
Oct 30, 2026
Merged

ptr727 merged 4 commits into
developfrom
fix/3634-pep723-comment-exempt

Conversation

@ptr727

@ptr727 ptr727 commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Implements #3634.

  • A PEP 723 block is now an instruction to a tool rather than a comment. The Python language data in prose-gate.json declares the block's form in a new metadata_block key: its opener, its content-line form, and its closer. metadata_block_lines in prose_lint.py returns the lines of each closed block in a comment unit. comment-added skips those lines.
  • comment-wrap and comment-case skip the same lines. Before, a block declaring one key reported comment-wrap on its opener, and the earlier test recorded that finding as one with "no remedy at all". The comments label does not reach that rule, and uv parses the block as written, so it cannot be reformatted. A block with a [tool.uv] table reported too. The new helper fixes that whole class of defect, so both rules now use it.
  • Only a closed block on the declared form is exempt. A prose line after the closer still reports. So does each line under an opener nothing closes, or under one whose block has a line off the form. The data is per language, so a shell file holding the same text still reports.
  • scripts/README.md states the exemption under comment-added. It replaces the run-based account of the PEP 723 opener in the configuration-run paragraph.

Verification

  • The prose_lint suite passes, with 641 tests run.
  • In the new comment-added test, a block followed by a prose line reports only the prose line. The unclosed, off-form, and non-Python cases each report exactly lines 1 and 2. Against develop's script the block reports lines 1 to 3.
  • The one key and tool table subtests report comment-wrap against develop and nothing here.
  • ruff format, ruff check, mypy, the eol gate, the diff-scoped prose gate with comment-added live, and a whole-tree prose run are clean.

Local review

Three passes ran at the frontier tier, and the last one is recorded at 0eec2d1 with no findings. The first round's comment-wrap finding and its loose subtest assertions were fixed in 531d0be. The second round's stale test docstring was fixed in 0eec2d1.

Pre-existing findings, filed

Pre-existing findings, not filed

  • scripts/README.md:112: "the exemption reaches six lines in three files" was already undercounted before this change, since every hub script's two-key PEP 723 block was itself a configuration run. Class pre-existing.

Declined findings

  • .github/actions/prose-gate/prose_lint.py metadata_block_lines: the review asked whether to share a scanner with front_matter_end. That function is anchored at index 0 over raw strings, while the new helper reads Line units at any position, so sharing one would mean generalizing the front-matter reader. Class: consolidation.

Closes on promotion: #3634

🤖 Generated with Claude Code

ptr727 and others added 3 commits October 30, 2026 12:09
The Python language data declares the block's opener, line form, and
closer, and comment-added skips each line of a closed block. A prose
line after the closer, or under an opener nothing closes, still
reports.

Closes #3634

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
comment-wrap and comment-case now skip a closed metadata block too, so
a PEP 723 block declaring one key no longer reports with no remedy.
The unclosed, off-form, and non-Python cases assert their exact lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The opener no longer clears through a configuration run, since both
rules skip a closed block whole, so its two-key case joins the block
test as a subtest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 30, 2026 19:18
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@ptr727

ptr727 commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 0eec2d149cf45eba0e79c53d2aadb87c294b5928, the content this pull request carries at that commit against develop, and it recorded 0 findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Two unresolved moderate findings remain: the metadata_block opener exempts every # /// <type> block rather than only # /// script, and comment_sentences still counts closed metadata-block lines toward sentence-length.

2 open issues
What changed in this PR

This PR exempts a PEP 723 inline script metadata block from the prose gate's comment rules. The block is an instruction to uv run --script, not a comment a person reads. Before this change, a script that added a # /// script block would fail comment-added, and a block with one key or a [tool.uv] table would fail comment-wrap. The exemption is declared per language in the prose-gate data, so a non-Python file with the same text is still checked. It only covers a closed block on the declared line form. Prose after the closer, or under an unclosed or malformed block, still reports.

Changes:

  • The Python language data declares a metadata_block form: an opener, a content-line pattern, and a closer.
  • A new helper, metadata_block_lines, returns the lines of each closed block in a comment unit. comment-added, comment-wrap, and comment-case skip those lines.
  • Tests cover a block followed by prose, unclosed, off-form, and non-Python cases, plus one-key and [tool.uv] block shapes. The README documents the exemption under comment-added.
File Description
tests/​test_prose_lint.py Adds tests for the block exemption, including closed, unclosed, off-form, non-Python, one-key, and tool-table cases. Replaces the older tests that expected a finding on a one-key block.
scripts/​README.md Documents the metadata block exemption under comment-added and the comment-wrap and comment-case rules, and replaces the run-based account of the opener.
.github/​actions/​prose-gate/​prose-gate.json Adds the Python metadata_block form (opener, content line, closer) that the helper reads.
.github/​actions/​prose-gate/​prose_lint.py Adds metadata_block_lines and applies it to comment-added, comment-wrap, and comment-case.

Review effort: Lite

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.72%. Comparing base (346f0ba) to head (03e0ba6).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3674   +/-   ##
========================================
  Coverage    81.72%   81.72%           
========================================
  Files           27       27           
  Lines         9128     9128           
========================================
  Hits          7460     7460           
  Misses        1668     1668           
Flag Coverage Δ
python-3.13 81.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Every comment rule now skips a closed PEP 723 block, sentence-length
and spelling among them, rather than only the rules that called the
helper. The opener is narrowed to the one standard type, script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727

ptr727 commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 03e0ba65b637aae21189ee0492dd1f951c191b65, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@ptr727
ptr727 merged commit e8ea7b1 into develop Oct 30, 2026
13 checks passed
@ptr727
ptr727 deleted the fix/3634-pep723-comment-exempt branch October 30, 2026 19:42
ptr727 added a commit that referenced this pull request Oct 30, 2026
…mment Rules (#3675)

Promotes the changes merged into `develop` since promotion #3667 to
`main`.

- [#3674](#3674) Exempts a
Python script's PEP 723 metadata block from every comment rule. The
block's lines leave the comment run before any rule reads it, and only a
closed `# /// script` block qualifies.

Closes #3634

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

2 participants