boolean (@NotNull PsiElement element) { final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element); if (virtualFile != null && ProjectRootManager.getInstance(element.getProject()).getFileIndex().isInLibraryClasses(virtualFile)) return false; if (element instanceof PyTargetExpression) { final PyAssignmentStatement assignmentStatement = PsiTreeUtil.getParentOfType(element, PyAssignmentStatement.class); if (assignmentStatement != null) { final PyExpression assignedValue = assignmentStatement.getAssignedValue(); if (assignedValue == null) return false; return isBooleanLiteral(assignedValue); } } if (element instanceof PyNamedParameter) { final PyExpression defaultValue = ((PyNamedParameter)element).getDefaultValue(); if (defaultValue != null && isBooleanLiteral(defaultValue)) { return true; } } return isBooleanLiteral(element.getParent()); }