mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[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:
parent
b89d61bd05
commit
671494a620
4 changed files with 55 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue