Skip to content

Commit

Permalink
feat(pagination): avoid fetching when has_more: false (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Feb 6, 2025
1 parent c5b700d commit 0cdb81d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/anthropic/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def _get_page_items(self) -> List[_T]:
return []
return data

@override
def has_next_page(self) -> bool:
has_more = self.has_more
if has_more is not None and has_more is False:
return False

return super().has_next_page()

@override
def next_page_info(self) -> Optional[PageInfo]:
if self._options.params.get("before_id"):
Expand Down Expand Up @@ -52,6 +60,14 @@ def _get_page_items(self) -> List[_T]:
return []
return data

@override
def has_next_page(self) -> bool:
has_more = self.has_more
if has_more is not None and has_more is False:
return False

return super().has_next_page()

@override
def next_page_info(self) -> Optional[PageInfo]:
if self._options.params.get("before_id"):
Expand Down

0 comments on commit 0cdb81d

Please sign in to comment.