PY-15985: Don't suggest replacing a chained assignment with an augmented assignment

GitOrigin-RevId: 6022b2b19e28b4ea424ee1022e07be328d636ad3
This commit is contained in:
Alex Grönholm
2025-02-25 17:23:16 +00:00
committed by intellij-monorepo-bot
parent 1fef7c549e
commit ae61422dff
3 changed files with 6 additions and 1 deletions
@@ -74,7 +74,7 @@ public final class PyAugmentAssignmentInspection extends PyInspection {
final PyExpression target = node.getLeftHandSideExpression();
final PyBinaryExpression value = PyUtil.as(node.getAssignedValue(), PyBinaryExpression.class);
if (target != null && value != null) {
if (target != null && value != null && node.getTargets().length == 1) {
final PyExpression leftExpression = value.getLeftExpression();
final PyExpression rightExpression = PyPsiUtils.flattenParens(value.getRightExpression());
@@ -0,0 +1,2 @@
var = 1
var = foo = var + 1
@@ -75,6 +75,9 @@ public class PyAugmentAssignmentInspectionTest extends PyInspectionTestCase {
runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest);
}
// PY-15985
public void testNotSuggestedForChainedTarget() { doTest(); }
@NotNull
@Override
protected Class<? extends PyInspection> getInspectionClass() {