void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement raiseStatement = descriptor.getPsiElement(); if (raiseStatement instanceof PyRaiseStatement) { PyExpression[] expressions = ((PyRaiseStatement)raiseStatement).getExpressions(); PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); String newExpressionText = expressions[0].getText() + "(" + expressions[1].getText() + ")"; if (expressions.length == 2) { raiseStatement.replace(elementGenerator.createFromText(LanguageLevel.forElement(raiseStatement), PyRaiseStatement.class, "raise " + newExpressionText)); } else if (expressions.length == 3) { raiseStatement.replace(elementGenerator.createFromText(LanguageLevel.forElement(raiseStatement), PyRaiseStatement.class, "raise " + newExpressionText + ".with_traceback(" + expressions[2].getText() + ")")); } } }