PY-33266 Don't show duplicate and nested warnings about redundant parentheses

We could duplicate them because in case like ((42)) we used to show one
warning for (42) as for parenthesized expression inside another one and
another warning for (42) as for parenthesized expression containing
a literal expression.
This commit is contained in:
Mikhail Golubev
2018-12-20 23:49:11 +07:00
parent 4bfd2668e4
commit ff1bb21ba8
3 changed files with 8 additions and 2 deletions
@@ -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);
@@ -0,0 +1 @@
x = (<weak_warning descr="Remove redundant parentheses">((42))</weak_warning>)
@@ -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();
}
}