def ensure_boolean(arg):
    """Checks whether given argument is a boolean value.
    :return: Argument, if it's a boolean
    :raise TypeError: When argument is not a boolean

    .. versionadded:: 0.0.3
    """
    if not isinstance(arg, bool):
        raise TypeError("expected a boolean, got %s" % type(arg).__name__)
    return arg
Checks whether given argument is a boolean value.
    :return: Argument, if it's a boolean
    :raise TypeError: When argument is not a boolean

    .. versionadded:: 0.0.3