Skip to content

chore(internal): codegen related update #583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions src/finch/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,17 @@ def next_page_info(self) -> Optional[PageInfo]:
length = len(self._get_page_items())
current_count = offset + length

return PageInfo(params={"offset": current_count})
count = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
if self.paging.count is not None:
count = self.paging.count
if count is None:
return None

if current_count < count:
return PageInfo(params={"offset": current_count})

return None


class AsyncIndividualsPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
Expand All @@ -171,7 +181,17 @@ def next_page_info(self) -> Optional[PageInfo]:
length = len(self._get_page_items())
current_count = offset + length

return PageInfo(params={"offset": current_count})
count = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
if self.paging.count is not None:
count = self.paging.count
if count is None:
return None

if current_count < count:
return PageInfo(params={"offset": current_count})

return None


class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
Expand All @@ -197,7 +217,17 @@ def next_page_info(self) -> Optional[PageInfo]:
length = len(self._get_page_items())
current_count = offset + length

return PageInfo(params={"offset": current_count})
count = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
if self.paging.count is not None:
count = self.paging.count
if count is None:
return None

if current_count < count:
return PageInfo(params={"offset": current_count})

return None


class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
Expand All @@ -223,4 +253,14 @@ def next_page_info(self) -> Optional[PageInfo]:
length = len(self._get_page_items())
current_count = offset + length

return PageInfo(params={"offset": current_count})
count = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
if self.paging.count is not None:
count = self.paging.count
if count is None:
return None

if current_count < count:
return PageInfo(params={"offset": current_count})

return None