public static boolean canSaveToTemp(final Project project, final String expression) {
    return ReadAction.compute(() -> {

      final PsiFile file = PyElementGenerator.getInstance(project).createDummyFile(LanguageLevel.getDefault(), expression);
      final PsiElement root = file.getFirstChild();
      return !isVariable(root) && (root instanceof PyExpressionStatement);
    });
  }
public static boolean canSaveToTemp(final Project project, final String expression)