---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
PLW0177 Comparing against a NaN value; use `math.isnan` instead
  --> nan_comparison.py:11:9
   |
10 | # PLW0117
11 | if x == float("nan"):
   |         ^^^^^^^^^^^^
12 |     pass
   |

PLW0177 Comparing against a NaN value; use `math.isnan` instead
  --> nan_comparison.py:15:9
   |
14 | # PLW0117
15 | if x == float("NaN"):
   |         ^^^^^^^^^^^^
16 |     pass
   |

PLW0177 Comparing against a NaN value; use `math.isnan` instead
  --> nan_comparison.py:19:9
   |
18 | # PLW0117
19 | if x == float("NAN"):
   |         ^^^^^^^^^^^^
20 |     pass
   |

PLW0177 Comparing against a NaN value; use `math.isnan` instead
  --> nan_comparison.py:23:9
   |
22 | # PLW0117
23 | if x == float("Nan"):
   |         ^^^^^^^^^^^^
24 |     pass
   |

PLW0177 Comparing against a NaN value; use `math.isnan` instead
  --> nan_comparison.py:27:9
   |
26 | # PLW0117
27 | if x == math.nan:
   |         ^^^^^^^^
28 |     pass
   |

PLW0177 Comparing against a NaN value; use `math.isnan` instead
  --> nan_comparison.py:31:9
   |
30 | # PLW0117
31 | if x == bad_val:
   |         ^^^^^^^
32 |     pass
   |

PLW0177 Comparing against a NaN value; use `np.isnan` instead
  --> nan_comparison.py:35:9
   |
34 | # PLW0117
35 | if y == np.NaN:
   |         ^^^^^^
36 |     pass
   |

PLW0177 Comparing against a NaN value; use `np.isnan` instead
  --> nan_comparison.py:39:9
   |
38 | # PLW0117
39 | if y == np.NAN:
   |         ^^^^^^
40 |     pass
   |

PLW0177 Comparing against a NaN value; use `np.isnan` instead
  --> nan_comparison.py:43:9
   |
42 | # PLW0117
43 | if y == np.nan:
   |         ^^^^^^
44 |     pass
   |

PLW0177 Comparing against a NaN value; use `np.isnan` instead
  --> nan_comparison.py:47:9
   |
46 | # PLW0117
47 | if y == npy_nan:
   |         ^^^^^^^
48 |     pass
   |

PLW0177 Comparing against a NaN value; use `math.isnan` instead
  --> nan_comparison.py:53:9
   |
52 | # PLW0117
53 | if x == builtins.float("nan"):
   |         ^^^^^^^^^^^^^^^^^^^^^
54 |     pass
   |

PLW0177 Comparing against a NaN value; use `np.isnan` instead
  --> nan_comparison.py:59:10
   |
57 | match number:
58 |     # Errors
59 |     case np.nan: ...
   |          ^^^^^^
60 |     case math.nan: ...
   |

PLW0177 Comparing against a NaN value; use `math.isnan` instead
  --> nan_comparison.py:60:10
   |
58 |     # Errors
59 |     case np.nan: ...
60 |     case math.nan: ...
   |          ^^^^^^^^
61 |
62 |     # No errors
   |

PLW0177 Comparing against a NaN value; use `math.isnan` instead
  --> nan_comparison.py:98:13
   |
96 | # PLW0117
97 | # https://github.com/astral-sh/ruff/issues/18596
98 | assert x == float("-NaN ")
   |             ^^^^^^^^^^^^^^
99 | assert x == float(" \n+nan   \t")
   |

PLW0177 Comparing against a NaN value; use `math.isnan` instead
  --> nan_comparison.py:99:13
   |
97 | # https://github.com/astral-sh/ruff/issues/18596
98 | assert x == float("-NaN ")
99 | assert x == float(" \n+nan   \t")
   |             ^^^^^^^^^^^^^^^^^^^^^
   |
