boolean (@NotNull Project project, Editor editor, PsiFile file) { if (!(file instanceof PyFile)) { return false; } final PyBinaryExpression expression = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyBinaryExpression.class); if (expression != null) { final PyElementType op = expression.getOperator(); if (op == PyTokenTypes.AND_KEYWORD || op == PyTokenTypes.OR_KEYWORD) { return true; } } return false; }