diff --git a/crates/ruff_linter/src/rules/pylint/rules/magic_value_comparison.rs b/crates/ruff_linter/src/rules/pylint/rules/magic_value_comparison.rs index 81e24c4ca603a..2bc7999066cbf 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/magic_value_comparison.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/magic_value_comparison.rs @@ -22,17 +22,23 @@ use crate::rules::pylint::settings::ConstantType; /// /// ## Example /// ```python -/// def calculate_discount(price: float) -> float: -/// return price * (1 - 0.2) +/// def apply_discount(price: float) -> float: +/// if price <= 100: +/// return price / 2 +/// else: +/// return price /// ``` /// /// Use instead: /// ```python -/// DISCOUNT_RATE = 0.2 +/// MAX_DISCOUNT = 100 /// /// -/// def calculate_discount(price: float) -> float: -/// return price * (1 - DISCOUNT_RATE) +/// def apply_discount(price: float) -> float: +/// if price <= MAX_DISCOUNT: +/// return price / 2 +/// else: +/// return price /// ``` /// /// [PEP 8]: https://peps.python.org/pep-0008/#constants