mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-18203 Redundant parentheses quick fix produces syntactically incorrect code for tuples
If parentheses expression contains binary expression where left and right are parentheses expressions too, we check if left and right contain tuples
This commit is contained in:
+2
-1
@@ -72,7 +72,8 @@ public class RedundantParenthesesQuickFix implements LocalQuickFix {
|
||||
right instanceof PyParenthesizedExpression) {
|
||||
PyExpression leftContained = ((PyParenthesizedExpression)left).getContainedExpression();
|
||||
PyExpression rightContained = ((PyParenthesizedExpression)right).getContainedExpression();
|
||||
if (leftContained != null && rightContained != null) {
|
||||
if (leftContained != null && rightContained != null &&
|
||||
!(leftContained instanceof PyTupleExpression) && !(rightContained instanceof PyTupleExpression)) {
|
||||
left.replace(leftContained);
|
||||
right.replace(rightContained);
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
print("%d%s%s" % (((1,) + <caret>("", ""))))
|
||||
@@ -0,0 +1 @@
|
||||
print("%d%s%s" % ((1,) + ("", "")))
|
||||
@@ -244,6 +244,11 @@ public class PyQuickFixTest extends PyTestCase {
|
||||
doInspectionTest(PyRedundantParenthesesInspection.class, PyBundle.message("QFIX.redundant.parentheses"), true, true);
|
||||
}
|
||||
|
||||
// PY-18203
|
||||
public void testRedundantParenthesesInTuples() {
|
||||
doInspectionTest(PyRedundantParenthesesInspection.class, PyBundle.message("QFIX.redundant.parentheses"), true, true);
|
||||
}
|
||||
|
||||
// PY-1020
|
||||
public void testChainedComparisons() {
|
||||
doInspectionTest(PyChainedComparisonsInspection.class, PyBundle.message("QFIX.chained.comparison"), true, true);
|
||||
|
||||
Reference in New Issue
Block a user