diff --git a/python/src/com/jetbrains/python/inspections/PyRedundantParenthesesInspection.java b/python/src/com/jetbrains/python/inspections/PyRedundantParenthesesInspection.java index e2b622c6cd18..fb793233f4ad 100644 --- a/python/src/com/jetbrains/python/inspections/PyRedundantParenthesesInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyRedundantParenthesesInspection.java @@ -83,6 +83,7 @@ public class PyRedundantParenthesesInspection extends PyInspection { @Override public void visitPyParenthesizedExpression(final PyParenthesizedExpression node) { if (node.textContains('\n')) return; + if (node.getParent() instanceof PyParenthesizedExpression) return; final PyExpression expression = node.getContainedExpression(); if (expression == null) return; final PyYieldExpression yieldExpression = PsiTreeUtil.getParentOfType(expression, PyYieldExpression.class, false); diff --git a/python/testData/inspections/PyRedundantParenthesesInspection/NestedParentheses.py b/python/testData/inspections/PyRedundantParenthesesInspection/NestedParentheses.py new file mode 100644 index 000000000000..a2e8576c830f --- /dev/null +++ b/python/testData/inspections/PyRedundantParenthesesInspection/NestedParentheses.py @@ -0,0 +1 @@ +x = (((42))) \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/inspections/PyRedundantParenthesesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyRedundantParenthesesInspectionTest.java index 7b3459ac69c5..43d427ceb2bf 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyRedundantParenthesesInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyRedundantParenthesesInspectionTest.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.inspections; -import com.intellij.testFramework.ExpectedHighlightingData; import com.jetbrains.python.fixtures.PyInspectionTestCase; import com.jetbrains.python.psi.LanguageLevel; import org.jetbrains.annotations.NotNull; @@ -56,7 +55,7 @@ public class PyRedundantParenthesesInspectionTest extends PyInspectionTestCase { } public void testTryExcept() { - ExpectedHighlightingData.expectedDuplicatedHighlighting(this::doTest); + doTest(); } public void testTryExceptNegate() { @@ -93,4 +92,9 @@ public class PyRedundantParenthesesInspectionTest extends PyInspectionTestCase { public void testReturn() { runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest); } + + // PY-33266 + public void testNestedParentheses() { + doTest(); + } }