Skip to content

Commit 57ff7a1

Browse files
committed
doc
1 parent ff2a5d5 commit 57ff7a1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/common-library/src/common_library/pagination_tools.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ def iter_pagination_params(
3434
offset: NonNegativeInt = 0,
3535
total_number_of_items: NonNegativeInt | None = None,
3636
) -> Iterable[PageParams]:
37+
"""Iterates through pages of a collection by yielding PageParams for each page.
38+
39+
Args:
40+
limit: The maximum number of items to return in a single page.
41+
offset: The number of items to skip before starting to collect the items for the current page.
42+
total_number_of_items: The total count of items in the collection being paginated.
43+
Must be set during the first iteration if not provided initially.
44+
45+
Yields:
46+
PageParams for each page in the collection.
47+
48+
Raises:
49+
RuntimeError: If total_number_of_items is not set before first iteration or if it changes between iterations.
50+
"""
3751

3852
kwargs = {}
3953
if total_number_of_items:

0 commit comments

Comments
 (0)