def cast_bool(s :str) -> bool:
    """
    Cast a string into a bool if possible.
    Args:
        s: The input str.
    Raises:
        ValueError: if the cast cannot be achieved.
    Returns:
        The boolean corresponding to s if successful.
    """
    if isinstance(s, bool):
        return s
    elif isinstance(s, str):
        l = s.lower()
        if l == "true":
            return True
        elif l == "false":
            return False
    raise ValueError("Invalid literal for cast_bool(): %s" % s)