void (final @NotNull PyParenthesizedExpression node) { if (node.textContains('\n')) return; final PsiElement parent = node.getParent(); if (parent instanceof PyParenthesizedExpression) return; final PyExpression expression = node.getContainedExpression(); if (expression == null || expression instanceof PyYieldExpression) return; if (expression instanceof PyTupleExpression && myIgnoreTupleInReturn) { return; } final LanguageLevel languageLevel = LanguageLevel.forElement(node); if (expression instanceof PyReferenceExpression || expression instanceof PyLiteralExpression) { if (myIgnorePercOperator) { if (parent instanceof PyBinaryExpression) { if (((PyBinaryExpression)parent).getOperator() == PyTokenTypes.PERC) return; } } if (expression instanceof PyNumericLiteralExpression && ((PyNumericLiteralExpression)expression).isIntegerLiteral() && parent instanceof PyReferenceExpression) { return; } if (parent instanceof PyPrintStatement) { return; } registerProblem(node, PyPsiBundle.message("QFIX.redundant.parentheses"), new RedundantParenthesesQuickFix()); } else if (parent instanceof PyIfPart || parent instanceof PyWhilePart) { registerProblem(node, PyPsiBundle.message("QFIX.redundant.parentheses"), new RedundantParenthesesQuickFix()); } else if (parent instanceof PyReturnStatement || parent instanceof PyYieldExpression) { if (!(isTupleWithUnpacking(expression) && languageLevel.isOlderThan(LanguageLevel.PYTHON38)) && !oneElementTuple(expression) && !isYieldFrom(parent)) { registerProblem(node, PyPsiBundle.message("QFIX.redundant.parentheses"), new RedundantParenthesesQuickFix()); } } else if (expression instanceof PyBinaryExpression binaryExpression) { if (parent instanceof PyPrefixExpression) { return; } if (binaryExpression.getOperator() == PyTokenTypes.AND_KEYWORD || binaryExpression.getOperator() == PyTokenTypes.OR_KEYWORD) { final PyExpression leftExpression = binaryExpression.getLeftExpression(); final PyExpression rightExpression = binaryExpression.getRightExpression(); if (leftExpression instanceof PyParenthesizedExpression && rightExpression instanceof PyParenthesizedExpression && !(((PyParenthesizedExpression)leftExpression).getContainedExpression() instanceof PyBinaryExpression) && !(((PyParenthesizedExpression)rightExpression).getContainedExpression() instanceof PyBinaryExpression)) { registerProblem(node, PyPsiBundle.message("QFIX.redundant.parentheses"), new RedundantParenthesesQuickFix()); } } } else if (expression instanceof PyParenthesizedExpression) { registerProblem(expression, PyPsiBundle.message("QFIX.redundant.parentheses"), new RedundantParenthesesQuickFix()); } }