Skip to content

Exempt a PEP 723 Script Metadata Block From comment-added #3634

Closed

Description

@ptr727

Defect

comment-added reads a PEP 723 inline script metadata block as prose. A change that adds one to a Python script fails the gate, for example a script that gains its first third-party import:

#!/usr/bin/env python3
# /// script
# requires-python = ">=3.13"
# dependencies = ["markdown-it-py>=4"]
# ///

The gate reports the first three comment lines of that block. The closing # /// line passes. The block is an instruction to uv run --script, and comment-and-doc-style says "an instruction to a tool is not a comment the rule reads". But tool_directives in .github/actions/prose-gate/prose-gate.json names no PEP 723 marker, so the block takes the comments label or PROSE_ALLOW_COMMENTS like any prose comment would.

Done Means

  • A PEP 723 block, from its # /// script opener through its # /// closer, is exempt from comment-added. The exemption is scoped to the block, so a prose comment line after the closer still reports.
  • A test adds such a block to a constructed Python file and reads no comment-added finding, plus one prose comment after it that does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    gatescript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions