Improve docs for non-augmented-assignment (PLR6104) (#12887)

This commit is contained in:
Alex Waygood 2024-08-14 10:50:00 +01:00 committed by GitHub
parent 3ddcad64f5
commit bebed67bf1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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