mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 22:31:23 +00:00
Improve docs for non-augmented-assignment
(PLR6104
) (#12887)
This commit is contained in:
parent
3ddcad64f5
commit
bebed67bf1
1 changed files with 6 additions and 6 deletions
|
@ -14,12 +14,12 @@ use crate::checkers::ast::Checker;
|
||||||
/// statements.
|
/// statements.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// If an assignment statement consists of a binary operation in which one
|
/// If the right-hand side of an assignment statement consists of a binary
|
||||||
/// operand is the same as the assignment target, it can be rewritten as an
|
/// operation in which one operand is the same as the assignment target,
|
||||||
/// augmented assignment. For example, `x = x + 1` can be rewritten as
|
/// it can be rewritten as an augmented assignment. For example, `x = x + 1
|
||||||
/// `x += 1`.
|
/// can be rewritten as `x += 1`.
|
||||||
///
|
///
|
||||||
/// When performing such an operation, augmented assignments are more concise
|
/// When performing such an operation, an augmented assignment is more concise
|
||||||
/// and idiomatic.
|
/// and idiomatic.
|
||||||
///
|
///
|
||||||
/// ## Known problems
|
/// ## Known problems
|
||||||
|
@ -31,7 +31,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// For example, `x = "prefix-" + x` is not equivalent to `x += "prefix-"`,
|
/// For example, `x = "prefix-" + x` is not equivalent to `x += "prefix-"`,
|
||||||
/// while `x = 1 + x` is equivalent to `x += 1`.
|
/// while `x = 1 + x` is equivalent to `x += 1`.
|
||||||
///
|
///
|
||||||
/// If the type of the left-hand side cannot be inferred trivially, the rule
|
/// If the type of the left-hand side cannot be trivially inferred, the rule
|
||||||
/// will ignore the assignment.
|
/// will ignore the assignment.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue