Calculates the maximum number of words that can be requested
        from a repack invocation with the given settings.

        This function can be called either on a BinArray instance (assuming
        its width as the source width), or on the BinArray class (passing
        the source width as an extra first argument).  If called in the
        second form, ``src_length`` must be provided.  Otherwise, it will
        default to the number of words in the source array from the given
        ``start`` index (defaulting to 0) until the end.

def repack_data_available(src_width, to_width, *,  # noqa: N805
                              src_length=None, start=None, start_bit=0):
        """Calculates the maximum number of words that can be requested
        from a repack invocation with the given settings.

        This function can be called either on a BinArray instance (assuming
        its width as the source width), or on the BinArray class (passing
        the source width as an extra first argument).  If called in the
        second form, ``src_length`` must be provided.  Otherwise, it will
        default to the number of words in the source array from the given
        ``start`` index (defaulting to 0) until the end.
        """
        start_bit = operator.index(start_bit)
        if isinstance(src_width, BinArray):
            self = src_width
            if src_length is None:
                if start is None:
                    start = 0
                else:
                    start = operator.index(start)
                    if start < 0:
                        raise ValueError('start must not be negative')
                src_length = len(self) - start
                start = None
            src_width = self.width
        if src_length is None:
            raise TypeError('no length given')
        if start is not None:
            raise TypeError('start is redundant with explicit src_length')
        src_width = operator.index(src_width)
        to_width = operator.index(to_width)
        src_length = operator.index(src_length)
        start_bit = operator.index(start_bit)
        if src_width <= 0:
            raise ValueError('source width must be positive')
        if to_width <= 0:
            raise ValueError('destination width must be positive')
        if src_length < 0:
            raise ValueError('src_length must not be negative')
        if start_bit not in range(src_width):
            raise ValueError('start bit must be in [0, src_width)')
        if src_length == 0 and start_bit != 0:
            raise ValueError(
                    'src_length must be positive if start_bit is not zero')
        return (src_width * src_length - start_bit) // to_width