diff --git a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyAugmentAssignmentInspection.java b/python/python-psi-impl/src/com/jetbrains/python/inspections/PyAugmentAssignmentInspection.java index 68774238ca9c..a5c8216269ad 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyAugmentAssignmentInspection.java +++ b/python/python-psi-impl/src/com/jetbrains/python/inspections/PyAugmentAssignmentInspection.java @@ -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()); diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/notSuggestedForChainedTarget.py b/python/testData/inspections/PyAugmentAssignmentInspection/notSuggestedForChainedTarget.py new file mode 100644 index 000000000000..241975434003 --- /dev/null +++ b/python/testData/inspections/PyAugmentAssignmentInspection/notSuggestedForChainedTarget.py @@ -0,0 +1,2 @@ +var = 1 +var = foo = var + 1 \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/inspections/PyAugmentAssignmentInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyAugmentAssignmentInspectionTest.java index 5b735e4e6a12..3bfa5cbf59bf 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyAugmentAssignmentInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyAugmentAssignmentInspectionTest.java @@ -75,6 +75,9 @@ public class PyAugmentAssignmentInspectionTest extends PyInspectionTestCase { runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest); } + // PY-15985 + public void testNotSuggestedForChainedTarget() { doTest(); } + @NotNull @Override protected Class getInspectionClass() {