void (@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { final PyElementGenerator generator = PyElementGenerator.getInstance(project); PsiElement element = descriptor.getPsiElement(); if (element == null) return; PsiFile file = element.getContainingFile(); final PyImportStatementBase statement = generator.createFromText(LanguageLevel.forElement(file), PyImportStatementBase.class, myImportToAdd); final PsiElement recommendedPosition = AddImportHelper.getFileInsertPosition(file); file.addAfter(statement, recommendedPosition); }