PyExpression (@NotNull String expressionText, @NotNull PsiElement context) { final PyExpressionCodeFragmentImpl codeFragment = new PyExpressionCodeFragmentImpl(context.getProject(), "dummy.py", expressionText, false); codeFragment.setContext(context); final PyExpressionStatement statement = as(codeFragment.getFirstChild(), PyExpressionStatement.class); return statement != null ? statement.getExpression() : null; }