Skip to content

Commit

Permalink
Improve magic-value-comparison example in docs (#8111)
Browse files Browse the repository at this point in the history
Closes #8109.
  • Loading branch information
charliermarsh authored Oct 21, 2023
1 parent 2414f23 commit 00fd324
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 00fd324

Please sign in to comment.