def parse_boolean(value):
    """
    Coerce a value to boolean.

    :param value: the value, could be a string, boolean, or None
    :return: the value as coerced to a boolean
    """

    if value is None:
        return None

    if isinstance(value, bool):
        return value

    if isinstance(value, string_types):
        value = value.lower()
        if value == 'false':
            return False
        if value == 'true':
            return True

    raise ValueError("Could not convert value to boolean: {}".format(value))
Coerce a value to boolean.

    :param value: the value, could be a string, boolean, or None
    :return: the value as coerced to a boolean