def _positive(index: int, size: int) -> int:
    """Convert a negative index to a non-negative integer.

    The index is interpreted relative to the position after the last item. If
    the index is smaller than ``-size``, IndexError is raised.
    """
    assert index < 0  # noqa: S101
    index += size

    if index < 0:
        raise IndexError("lazysequence index out of range")

    return index