Skip to content

Commit 9bd789d

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
chore(internal): codegen related update (#535)
1 parent c6b1c6e commit 9bd789d

File tree

1 file changed

+12
-44
lines changed

1 file changed

+12
-44
lines changed

src/finch/pagination.py

+12-44
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,15 @@ def _get_page_items(self) -> List[_T]:
136136
def next_page_info(self) -> Optional[PageInfo]:
137137
offset = None
138138
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
139-
offset = self.paging.offset
139+
if self.paging.offset is not None:
140+
offset = self.paging.offset
140141
if offset is None:
141142
return None
142143

143144
length = len(self._get_page_items())
144145
current_count = offset + length
145146

146-
count = None
147-
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
148-
count = self.paging.count
149-
if count is None:
150-
return None
151-
152-
if current_count < count:
153-
return PageInfo(params={"offset": current_count})
154-
155-
return None
147+
return PageInfo(params={"offset": current_count})
156148

157149

158150
class AsyncIndividualsPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
@@ -171,23 +163,15 @@ def _get_page_items(self) -> List[_T]:
171163
def next_page_info(self) -> Optional[PageInfo]:
172164
offset = None
173165
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
174-
offset = self.paging.offset
166+
if self.paging.offset is not None:
167+
offset = self.paging.offset
175168
if offset is None:
176169
return None
177170

178171
length = len(self._get_page_items())
179172
current_count = offset + length
180173

181-
count = None
182-
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
183-
count = self.paging.count
184-
if count is None:
185-
return None
186-
187-
if current_count < count:
188-
return PageInfo(params={"offset": current_count})
189-
190-
return None
174+
return PageInfo(params={"offset": current_count})
191175

192176

193177
class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
@@ -205,23 +189,15 @@ def _get_page_items(self) -> List[_T]:
205189
def next_page_info(self) -> Optional[PageInfo]:
206190
offset = None
207191
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
208-
offset = self.paging.offset
192+
if self.paging.offset is not None:
193+
offset = self.paging.offset
209194
if offset is None:
210195
return None
211196

212197
length = len(self._get_page_items())
213198
current_count = offset + length
214199

215-
count = None
216-
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
217-
count = self.paging.count
218-
if count is None:
219-
return None
220-
221-
if current_count < count:
222-
return PageInfo(params={"offset": current_count})
223-
224-
return None
200+
return PageInfo(params={"offset": current_count})
225201

226202

227203
class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
@@ -239,20 +215,12 @@ def _get_page_items(self) -> List[_T]:
239215
def next_page_info(self) -> Optional[PageInfo]:
240216
offset = None
241217
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
242-
offset = self.paging.offset
218+
if self.paging.offset is not None:
219+
offset = self.paging.offset
243220
if offset is None:
244221
return None
245222

246223
length = len(self._get_page_items())
247224
current_count = offset + length
248225

249-
count = None
250-
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
251-
count = self.paging.count
252-
if count is None:
253-
return None
254-
255-
if current_count < count:
256-
return PageInfo(params={"offset": current_count})
257-
258-
return None
226+
return PageInfo(params={"offset": current_count})

0 commit comments

Comments
 (0)