mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:21 +00:00
Improve magic-value-comparison
example in docs (#8111)
Closes https://github.com/astral-sh/ruff/issues/8109.
This commit is contained in:
parent
2414f23abb
commit
00fd324c6f
1 changed files with 11 additions and 5 deletions
|
@ -22,17 +22,23 @@ use crate::rules::pylint::settings::ConstantType;
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
/// def calculate_discount(price: float) -> float:
|
/// def apply_discount(price: float) -> float:
|
||||||
/// return price * (1 - 0.2)
|
/// if price <= 100:
|
||||||
|
/// return price / 2
|
||||||
|
/// else:
|
||||||
|
/// return price
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Use instead:
|
/// Use instead:
|
||||||
/// ```python
|
/// ```python
|
||||||
/// DISCOUNT_RATE = 0.2
|
/// MAX_DISCOUNT = 100
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
/// def calculate_discount(price: float) -> float:
|
/// def apply_discount(price: float) -> float:
|
||||||
/// return price * (1 - DISCOUNT_RATE)
|
/// if price <= MAX_DISCOUNT:
|
||||||
|
/// return price / 2
|
||||||
|
/// else:
|
||||||
|
/// return price
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [PEP 8]: https://peps.python.org/pep-0008/#constants
|
/// [PEP 8]: https://peps.python.org/pep-0008/#constants
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue