Skip to content

Commit

Permalink
Extend BasePaginator and BaseReferencePaginator docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
burnash committed Apr 25, 2024
1 parent b8771df commit 3fe37ae
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions dlt/sources/helpers/rest_client/paginators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@


class BasePaginator(ABC):
"""
Base class for all paginator implementations. Paginators are used
"""A base class for all paginator implementations. Paginators are used
to handle paginated responses from RESTful APIs.
See `RESTClient.paginate()` for example usage.
Expand All @@ -32,7 +31,8 @@ def update_state(self, response: Response) -> None:
This method should extract necessary pagination details (like next page
references) from the response and update the paginator's state
accordingly.
accordingly. It should also set the `_has_next_page` attribute to
indicate if there is a next page available.
Args:
response (Response): The response object from the API request.
Expand Down Expand Up @@ -162,6 +162,15 @@ def update_request(self, request: Request) -> None:


class BaseReferencePaginator(BasePaginator):
"""A base paginator class for paginators that use a reference to the next
page, such as a URL or a cursor string.
Subclasses should implement:
1. `update_state` method to extract the next page reference and
set the `_next_reference` attribute accordingly.
2. `update_request` method to update the request object with the next
page reference.
"""
def __init__(self) -> None:
super().__init__()
self.__next_reference: Optional[str] = None
Expand Down Expand Up @@ -195,7 +204,7 @@ class BaseNextUrlPaginator(BaseReferencePaginator):
headers or in the JSON response.
Subclasses should implement the `update_state` method to extract the next
page URL and set the `next_reference` attribute accordingly.
page URL and set the `_next_reference` attribute accordingly.
See `HeaderLinkPaginator` and `JSONResponsePaginator` for examples.
"""
Expand Down

0 comments on commit 3fe37ae

Please sign in to comment.