Skip to content

Promote Develop: Exempt the PEP 723 Script Metadata Block From the Comment Rules - #3675

Merged
ptr727 merged 1 commit into
mainfrom
develop
Oct 30, 2026
Merged

ptr727 merged 1 commit into
mainfrom
develop

Conversation

@ptr727

@ptr727 ptr727 commented Oct 30, 2026

Copy link
Copy Markdown
Owner

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

  • #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

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

- An extensionless script whose shebang is `#!/usr/bin/env -S uv run
--script` is read with the `bash` lexer, so it gets none of the Python
reading. Filed as #3673, class `pre-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. 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](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 30, 2026 19:42
@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.

@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 (e8ea7b1).
⚠️ Report is 449 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3675   +/-   ##
=======================================
  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.

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.

🟢 Approval recommended

No active review issues remain for the proposed metadata-block exemption and its covered boundary cases.

No open issues 🎉

What changed in this PR

This pull request promotes the PEP 723 metadata-block exemption from develop to main, preventing valid Python script metadata from being evaluated as prose comments.

Changes:

  • Defines Python PEP 723 metadata-block syntax in the prose-gate configuration.
  • Excludes closed metadata blocks before comment rules run.
  • Adds regression coverage for valid, invalid, unclosed, non-Python, and post-block cases.
  • Documents the exemption and its scope.

This pull request requires changes.

File Summary
tests/​test_prose_lint.py Tests metadata-block handling across comment rules and boundary cases.
scripts/​README.md Documents the PEP 723 exemption and its scope.
.github/​actions/​prose-gate/​prose-gate.json Defines the Python metadata-block opener, content form, and closer.
.github/​actions/​prose-gate/​prose_lint.py Removes closed metadata blocks from comment units before rule evaluation.

Review effort: Lite

@ptr727
ptr727 merged commit ee7839b into main Oct 30, 2026
14 checks passed
ptr727 added a commit that referenced this pull request Oct 30, 2026
…3678)

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

- [#3676](#3676) Reads a
`uv run` shebang as Python in the prose gate. A new `files.runner` map
in the gate's data names the interpreter a runner runs, so an
extensionless `uv run --script` file gets the Python reading, the PEP
723 metadata block exemption among it.

Closes #3673

🤖 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.

Exempt a PEP 723 Script Metadata Block From comment-added

2 participants