void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { final PsiElement element = descriptor.getPsiElement(); if (element instanceof PyCallExpression) { PyExpression callee = ((PyCallExpression)element).getCallee(); if (callee instanceof PyReferenceExpression) { final PsiPolyVariantReference reference = ((PyReferenceExpression)callee).getReference(); PsiElement psiElement = reference.resolve(); if (psiElement instanceof PyClass) { final PyElementGenerator generator = PyElementGenerator.getInstance(project); final PyArgumentList list = ((PyClass)psiElement).getSuperClassExpressionList(); if (list != null) { final PyExpression exception = generator.createExpressionFromText(LanguageLevel.forElement(element), "Exception"); list.addArgument(exception); } else { final PyArgumentList expressionList = generator.createFromText( LanguageLevel.forElement(element), PyClass.class, "class A(Exception): pass").getSuperClassExpressionList(); assert expressionList != null; final ASTNode nameNode = ((PyClass)psiElement).getNameNode(); assert nameNode != null; final PsiElement oldArgList = nameNode.getPsi().getNextSibling(); oldArgList.replace(expressionList); } } } } }