Checks whether argument is a tuple.
    :param len_: Optional expected length of the tuple
    :return: Argument, if it's a tuple (of given length, if any)
    :raise TypeError: When argument is not a tuple (of given length, if any)

def ensure_tuple(arg, len_=None):
    """Checks whether argument is a tuple.
    :param len_: Optional expected length of the tuple
    :return: Argument, if it's a tuple (of given length, if any)
    :raise TypeError: When argument is not a tuple (of given length, if any)
    """
    if not is_tuple(arg, len_=len_):
        len_part = "" if len_ is None else " of length %s" % len_
        raise TypeError(
            "expected tuple%s, got %s" % (len_part, _describe_type(arg)))
    return arg