void (@NotNull PsiElement elementTpReplace, @NotNull PsiElement elementInUnpack, @NotNull PsiFile file, @NotNull Project project) { AddImportHelper.addOrUpdateFromImportStatement(file, "typing_extensions", "Unpack", null, AddImportHelper.ImportPriority.FUTURE, null); String unpacked = "Unpack[" + elementInUnpack.getText() + "]"; PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); PyExpressionStatement expressionStatement = elementGenerator.createFromText(LanguageLevel.forElement(elementInUnpack), PyExpressionStatement.class, unpacked); PyExpression newElement = expressionStatement.getExpression(); elementTpReplace.replace(newElement); }