def to_bool(arg):
    """
    Return a boolean value based on `arg`.
    """
    if arg is None or isinstance(arg, bool):
        return arg
    if isinstance(arg, str):
        arg = arg.lower()
    if arg in ('yes', 'on', '1', 'true', 1):
        return True
    return False
