Skip to content

ERA001 stops parsing an inline script metadata block at the first # /// line #13278

@dscorbett

Description

@dscorbett

ERA001 skips PEP 723 inline script metadata blocks as of #10455, except that it stops skipping after the first # /// line. However, a metadata block continues if the following lines are valid embedded content followed by another # /// line. ERA001 should skip over the full metadata block.

For example, this script (named era001.py) contains metadata with an embedded # /// line.

# /// script
# [tool.uv]
# extra-index-url = ["https://pypi.org/simple", """\
# https://example.com/
# ///
# """
# ]
# ///
print(1)

The script works, which shows that the first # /// line does not end the block. (I am using uv, but this could work with any tool that interprets inline metadata.)

$ uv version
uv 0.4.7 (a178051e8 2024-09-07)
$ uv run era001.py
Reading inline script metadata from: era001.py
1

However, Ruff reports an error.

$ ruff --version
ruff 0.6.4
$ ruff check --isolated --select ERA001 era001.py
era001.py:7:1: ERA001 Found commented-out code
  |
5 | # ///
6 | # """
7 | # ]
  | ^^^ ERA001
8 | # ///
9 | print(1)
  |
  = help: Remove commented-out code

Found 1 error.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingruleImplementing or modifying a lint rule

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions