boolean (@NotNull PsiElement element) { ScopeOwner owner = ScopeUtil.getScopeOwner(element); if (!(owner instanceof PyFile)) return false; PyExpressionStatement statement = PsiTreeUtil.getParentOfType(element, PyExpressionStatement.class); return statement != null && statement.getParent() instanceof PyFile; }