from typing import Union
from typing import Optional


def to_bool(value: Union[str,bool,int]) -> Optional[bool]:
    """Convert a string to boolean. True values: 1, yes, true, false values:
    0, no, false, otherwise returns `None`."""

    if isinstance(value, bool):
        return value
    elif isinstance(value, int):
        return bool(value)
    elif isinstance(value, str):

        lower: str = value.lower()

        if lower in ("1", "true", "yes"):
            return True
        elif lower in ("0", "false", "no"):
            return False
        else:
            return None
    else:
        raise TypeError("Can't convert value of type '{}"
                        "to bool".format(type(value)))