Warn on invalid noqa even when there are no diagnostics (#16178)

On `main` we warn the user if there is an invalid noqa comment[^1] and
at least one of the following holds:

- There is at least one diagnostic
- A lint rule related to `noqa`s is enabled (e.g. `RUF100`)

This is probably strange behavior from the point of view of the user, so
we now show invalid `noqa`s even when there are no diagnostics.

Closes #12831

[^1]: For the current definition of "invalid noqa comment", which may be
expanded in #12811 . This PR is independent of loc. cit. in the sense
that the CLI warnings should be consistent, regardless of which `noqa`
comments are considered invalid.
This commit is contained in:
Dylan 2025-02-16 13:58:18 -06:00 committed by GitHub
parent 3a0d45c85b
commit f29c7b03ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 1 deletions

View file

@ -267,7 +267,7 @@ pub fn check_path(
}
// Enforce `noqa` directives.
if (noqa.is_enabled() && !diagnostics.is_empty())
if noqa.is_enabled()
|| settings
.rules
.iter_enabled()