void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); if (myAnnotation != null) { PyAnnotation annotation = myAnnotation.getElement(); if (annotation != null) { PyExpression annotationExpr = annotation.getValue(); if (annotationExpr == null) return; PsiElement newElement = annotationExpr.replace(elementGenerator.createExpressionFromText(LanguageLevel.PYTHON34, myReturnTypeName)); addImportsForTypeAnnotations(newElement); } } else if (myTypeCommentAnnotation != null) { PsiComment typeComment = myTypeCommentAnnotation.getElement(); if (typeComment != null) { StringBuilder typeCommentAnnotation = new StringBuilder(typeComment.getText()); typeCommentAnnotation.delete(typeCommentAnnotation.indexOf("->"), typeCommentAnnotation.length()); typeCommentAnnotation.append("-> ").append(myReturnTypeName); PsiComment newTypeComment = elementGenerator.createFromText(LanguageLevel.PYTHON27, PsiComment.class, typeCommentAnnotation.toString()); PsiElement newElement = typeComment.replace(newTypeComment); addImportsForTypeAnnotations(newElement); } } }