Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve magic-value-comparison example in docs #8111

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improve magic-value-comparison example in docs
  • Loading branch information
charliermarsh committed Oct 21, 2023
commit 8e2d8c70ef98738e6d50dc3244f81727e5e08d57
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
Loading