void (@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { final PyFunction problemFunction = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PyFunction.class); if (problemFunction == null) return; final StringBuilder superCall = new StringBuilder(); final PyClass klass = problemFunction.getContainingClass(); if (klass == null) return; final PyClass[] superClasses = klass.getSuperClasses(null); if (superClasses.length == 0) return; final PyClass superClass = superClasses[0]; final PyFunction superInit = superClass.findMethodByName(PyNames.INIT, true, null); if (superInit == null) return; final ParametersInfo origInfo = new ParametersInfo(problemFunction.getParameterList()); final ParametersInfo superInfo = new ParametersInfo(superInit.getParameterList()); final boolean addSelfToCall; if (klass.isNewStyleClass(null)) { addSelfToCall = false; if (LanguageLevel.forElement(klass).isPy3K()) { superCall.append("super().__init__("); } else { superCall.append("super(").append(klass.getName()).append(", ").append(getSelfParameterName(origInfo)).append(").__init__("); } } else { addSelfToCall = true; superCall.append(superClass.getName()).append(".__init__("); } final Couple<List<String>> couple = buildNewFunctionParamsAndSuperInitCallArgs(origInfo, superInfo, addSelfToCall); final StringBuilder newParameters = new StringBuilder("("); StringUtil.join(couple.getFirst(), ", ", newParameters); newParameters.append(")"); StringUtil.join(couple.getSecond(), ", ", superCall); superCall.append(")"); final PyElementGenerator generator = PyElementGenerator.getInstance(project); final LanguageLevel languageLevel = LanguageLevel.forElement(problemFunction); final PyStatement callSuperStatement = generator.createFromText(languageLevel, PyStatement.class, superCall.toString()); final PyParameterList newParameterList = generator.createParameterList(languageLevel, newParameters.toString()); problemFunction.getParameterList().replace(newParameterList); final PyStatementList statementList = problemFunction.getStatementList(); PyPsiRefactoringUtil.addElementToStatementList(callSuperStatement, statementList, true); PyPsiUtils.removeRedundantPass(statementList); }