ruff icon indicating copy to clipboard operation
ruff copied to clipboard

"Invalid `# ruff: noqa`" warnings should be an error

Open DetachHead opened this issue 2 years ago • 2 comments

# ruff: noqa: asdfas
>ruff asdf.py
warning: Invalid `# ruff: noqa` directive at asdf.py:1: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).

currently there seems to be no way to make ruff fail on invalid noqa comments. i think this should be a normal rule that causes ruff to fail, not a warning.

DetachHead avatar Oct 24 '23 06:10 DetachHead

It does seems reasonable to include a rule code for this, but given that we cannot parse the noqa directive it could be troublesome as you won't be able to ignore problems.

Separately from whether or not this is something we want, I think it'd be a little tricky to implement.

zanieb avatar Oct 24 '23 16:10 zanieb

I have this warning too, but in my case it was caused by the use of noga: 501 which apparently works for flake8 but causes the warning for ruff. We addressed that by changing that to noga: E501.

However, since flake8 supports the notation noga: 501, it would probably be good if ruff did that, too.

Apart from that, I tend to agree that invalid noqa statements should be errors.

andy-maier avatar Apr 09 '24 07:04 andy-maier