import typing


def parse_bool(data: typing.Optional[typing.Union[str, bool]]) -> bool:
    """
    Try to parse booleans from strings.

    On success, it returns the parsed boolean on failure it raises a TypeError.

    Usage:
        >>> parse_bool("YES")
        True
        >>> parse_bool("false")
        False
        >>> parse_bool("/etc/passwd")
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        TypeError: Not a boolean value
    """
    if isinstance(data, bool):
        return data
    if isinstance(data, str):
        val = data.lower()
        if val in ["yes", "true", "on", "1", 1]:
            return True
        elif val in ["no", "false", "off", "0", 0]:
            return False

    raise TypeError("Value is not a boolean")