Skip to content

ruff:ignore doesn't work in nested comments #25547

@ntBre

Description

@ntBre

Our noqa parsing still considers the trailing or nested comment on the second line to be a valid suppression, but our ruff:ignore parsing does not. The first three lines suppress F401, but the last doesn't:

import math  # noqa: F401
import math  # some comment  # noqa: F401

import math  # ruff:ignore[F401]
import math  # some comment  # ruff:ignore[F401]

Playground

ty also captures the noqa behavior, so this seems like a bug in our ruff:ignore handling:

main.py:

x: str = 1  # ty:ignore[invalid-assignment]
x: str = 1  # some comment  # ty:ignore[invalid-assignment]

Playground

This came up while I was working on #25537 and thought of #25414.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsuppressionRelated to supression of violations e.g. noqa

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions