mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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:
@@ -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>)
|
||||
+6
-2
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user