Skip to content
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

chore(internal): codegen related update #535

Merged
merged 1 commit into from
Nov 29, 2024
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
56 changes: 12 additions & 44 deletions src/finch/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,15 @@ def _get_page_items(self) -> List[_T]:
def next_page_info(self) -> Optional[PageInfo]:
offset = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
offset = self.paging.offset
if self.paging.offset is not None:
offset = self.paging.offset
if offset is None:
return None

length = len(self._get_page_items())
current_count = offset + length

count = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
count = self.paging.count
if count is None:
return None

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

return None
return PageInfo(params={"offset": current_count})


class AsyncIndividualsPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
Expand All @@ -171,23 +163,15 @@ def _get_page_items(self) -> List[_T]:
def next_page_info(self) -> Optional[PageInfo]:
offset = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
offset = self.paging.offset
if self.paging.offset is not None:
offset = self.paging.offset
if offset is None:
return None

length = len(self._get_page_items())
current_count = offset + length

count = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
count = self.paging.count
if count is None:
return None

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

return None
return PageInfo(params={"offset": current_count})


class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
Expand All @@ -205,23 +189,15 @@ def _get_page_items(self) -> List[_T]:
def next_page_info(self) -> Optional[PageInfo]:
offset = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
offset = self.paging.offset
if self.paging.offset is not None:
offset = self.paging.offset
if offset is None:
return None

length = len(self._get_page_items())
current_count = offset + length

count = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
count = self.paging.count
if count is None:
return None

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

return None
return PageInfo(params={"offset": current_count})


class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
Expand All @@ -239,20 +215,12 @@ def _get_page_items(self) -> List[_T]:
def next_page_info(self) -> Optional[PageInfo]:
offset = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
offset = self.paging.offset
if self.paging.offset is not None:
offset = self.paging.offset
if offset is None:
return None

length = len(self._get_page_items())
current_count = offset + length

count = None
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
count = self.paging.count
if count is None:
return None

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

return None
return PageInfo(params={"offset": current_count})