[pylint] Also reports case np.nan/case math.nan (PLW0177) (#16378)

## Summary

Resolves #16374.

`PLW0177` now also reports the pattern of a case branch if it is an
attribute access whose qualified name is that of either `np.nan` or
`math.nan`.

As the rule is in preview, the changes are not preview-gated.

## Test Plan

`cargo nextest run` and `cargo insta test`.
This commit is contained in:
InSync 2025-02-27 01:50:21 +07:00 committed by GitHub
parent b89d61bd05
commit 671494a620
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 55 additions and 2 deletions

View file

@ -53,6 +53,18 @@ import builtins
if x == builtins.float("nan"):
pass
# https://github.com/astral-sh/ruff/issues/16374
match number:
# Errors
case np.nan: ...
case math.nan: ...
# No errors
case np.nan(): ...
case math.nan(): ...
case float('nan'): ...
case npy_nan: ...
# OK
if math.isnan(x):
pass