`ruff:ignore` doesn't work in nested comments
bugsuppression
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:
```py
import math # noqa: F401
import math # some comment # noqa: F401
import math # ruff:ignore[F401]
import math # some comment # ruff:ignore[F401]
```
[Playground](https://play.ruff.rs/8f2c5463-f087-46e2-8e7b-029872f86c4f)
ty also captures the `noqa` behavior, so this seems like a bug in our `ruff:ignore` handling:
`main.py`:
```py
x: str = 1 # ty:ignore[invalid-assignment]
x: str = 1 # some comment # ty:ignore[invalid-assignment]
```
[Playground](https://play.ty.dev/ad71210c-84c6-45cd-b0d3-642922c0efc5)
This came up while I was working on #25537 and thought of https://github.com/astral-sh/ruff/pull/25414.
0 条评论