Skip to content

ERA001 false positive inside inline script metadata with trailing additional comment #15321

@Julian

Description

@Julian

This code:

#!/usr/bin/env python3
# /// script
# requires-python = ">=3.12"
# dependencies = [
#   "rich-click",
#   "imagehash",
# ]
# ///
#
# Bla bla bla
#
#   $ ruff check --select ALL --ignore A001,D200,D203,D212 phototool
"""
Do important things.
"""
print(__doc__)

when checked via ruff check --select ERA001 incorrectly flags:

test.py:4:1: ERA001 Found commented-out code
  |
2 | # /// script
3 | # requires-python = ">=3.12"
4 | # dependencies = [
  | ^^^^^^^^^^^^^^^^^^ ERA001
5 | #   "rich-click",
6 | #   "imagehash",
  |
  = help: Remove commented-out code

test.py:7:1: ERA001 Found commented-out code
  |
5 | #   "rich-click",
6 | #   "imagehash",
7 | # ]
  | ^^^ ERA001
8 | # ///
9 | #
  |
  = help: Remove commented-out code

There are one or two other ERA001 issues open but perhaps this one is narrowly scoped in that ISTM maybe "never flag ERA001 inside an inline script block" might be an isolateable fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedContributions especially welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions