boolean (@NotNull Project project, Editor editor, PsiFile file) { if (!(file instanceof PyFile)) { return false; } PyListCompExpression expression = PsiTreeUtil.getTopmostParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyListCompExpression.class); if (expression == null) { return false; } if (expression.getComponents().isEmpty()) return false; PsiElement parent = expression.getParent(); if (parent instanceof PyAssignmentStatement || parent instanceof PyPrintStatement) { return true; } return false; }