diff --git a/crates/ruff_linter/src/rules/pylint/rules/comparison_with_itself.rs b/crates/ruff_linter/src/rules/pylint/rules/comparison_with_itself.rs index ce02b12fff..8aa58e70e8 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/comparison_with_itself.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/comparison_with_itself.rs @@ -21,6 +21,14 @@ use crate::rules::pylint::helpers::CmpOpExt; /// foo == foo /// ``` /// +/// In some cases, self-comparisons are used to determine whether a float is +/// NaN. Instead, prefer `math.isnan`: +/// ```python +/// import math +/// +/// math.isnan(foo) +/// ``` +/// /// ## References /// - [Python documentation: Comparisons](https://docs.python.org/3/reference/expressions.html#comparisons) #[violation]