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

      final PsiFile file = PyElementGenerator.getInstance(project).createDummyFile(LanguageLevel.getDefault(), expression);
      return file.getFirstChild() instanceof PyExpressionStatement && file.getFirstChild() == file.getLastChild();
    });
  }
public static boolean isExpression(final Project project, final String expression)