Repository navigation
Exempt a PEP 723 Script Metadata Block From the Comment Rules - #3674
Conversation
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>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
A recorded local strict-review pass covers head |
There was a problem hiding this comment.
🟡 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_blockform: 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, andcomment-caseskip 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 undercomment-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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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>
|
A recorded local strict-review pass covers head |
…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)

Implements #3634.
prose-gate.jsondeclares the block's form in a newmetadata_blockkey: its opener, its content-line form, and its closer.metadata_block_linesinprose_lint.pyreturns the lines of each closed block in a comment unit.comment-addedskips those lines.comment-wrapandcomment-caseskip the same lines. Before, a block declaring one key reportedcomment-wrapon its opener, and the earlier test recorded that finding as one with "no remedy at all". Thecommentslabel does not reach that rule, anduvparses 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.scripts/README.mdstates the exemption undercomment-added. It replaces the run-based account of the PEP 723 opener in the configuration-run paragraph.Verification
prose_lintsuite passes, with 641 tests run.comment-addedtest, 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.one keyandtool tablesubtests reportcomment-wrapagainst develop and nothing here.comment-addedlive, and a whole-tree prose run are clean.Local review
Three passes ran at the
frontiertier, and the last one is recorded at0eec2d1with no findings. The first round'scomment-wrapfinding and its loose subtest assertions were fixed in531d0be. The second round's stale test docstring was fixed in0eec2d1.Pre-existing findings, filed
#!/usr/bin/env -S uv run --scriptis read with thebashlexer, so it gets none of the Python reading. Filed as Read a uv run Shebang as Python in the Prose Gate #3673, classpre-existing.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. Classpre-existing.Declined findings
.github/actions/prose-gate/prose_lint.pymetadata_block_lines: the review asked whether to share a scanner withfront_matter_end. That function is anchored at index 0 over raw strings, while the new helper readsLineunits at any position, so sharing one would mean generalizing the front-matter reader. Class: consolidation.Closes on promotion: #3634
🤖 Generated with Claude Code