If parentheses expression contains binary expression where left and right are parentheses expressions too, we check if left and right contain tuples
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;
--- /dev/null
+print("%d%s%s" % (((1,) + <caret>("", ""))))
\ No newline at end of file
--- /dev/null
+print("%d%s%s" % ((1,) + ("", "")))
\ No newline at end of file
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);