GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add recommendation for "escaping" quoted inline script metadata · Issue #1835 · pypa/packaging.python.org

Add recommendation for "escaping" quoted inline script metadata #1835

New issue
Copy link
New issue
Copy link
Open
#2139
Open
Add recommendation for "escaping" quoted inline script metadata#1835
#2139
Copy link

Description

@ncoghlan
ncoghlan
opened on Mar 21, 2025
Issue body actions

Issue Description

As described in astral-sh/uv#12303, inline script metadata added naively to a multi-line string will be incorrectly detected as being actual inline script metadata when parsed in accordance with PEP 723 (since the parsing rules are written to be compatible with a basic regex instead of requiring a full Python parser).

https://packaging.python.org/en/latest/specifications/inline-script-metadata/#recommendations should note the problem, and suggest ways to use Python's string quoting flexibility to avoid the misfire.

For example, replacing:

SOURCE_CODE = """
# /// script
# dependencies = ["pydantic", "email-validator"]
# ///
import pydantic

class Model(pydantic.BaseModel):
    email: pydantic.EmailStr

print(Model(email='[email protected]'))
"""

with the following compile time string concatenation:

SOURCE_CODE = ("""
"""
"# /// script"
"""
# dependencies = ["pydantic", "email-validator"]
# ///
import pydantic

class Model(pydantic.BaseModel):
    email: pydantic.EmailStr

print(Model(email='[email protected]'))
""")

Code of Conduct

  • I am aware that participants in this repository must follow the PSF Code of Conduct.
Reacted by Karl Knechtel

Activity

  1. brettcannon commented on Nov 2, 2026

    @brettcannon
    brettcannon
    on Nov 2, 2026
    Member
    More actions

    I think it's fine to note the problem, but I think the solution is a bit too clever, niche, and too specific to parsing the AST.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.