From c479227d4d92ef4f58825e297a926116ab1a2d32 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Fri, 29 Nov 2024 18:54:09 +0000 Subject: [PATCH] chore(internal): codegen related update --- src/finch/pagination.py | 56 +++++++++-------------------------------- 1 file changed, 12 insertions(+), 44 deletions(-) diff --git a/src/finch/pagination.py b/src/finch/pagination.py index 33ed744d..c2afd69f 100644 --- a/src/finch/pagination.py +++ b/src/finch/pagination.py @@ -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]): @@ -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]): @@ -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]): @@ -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})