7
7
from ._models import BaseModel
8
8
from ._base_client import BasePage , PageInfo , BaseSyncPage , BaseAsyncPage
9
9
10
- __all__ = ["SyncPage" , "AsyncPage" ]
10
+ __all__ = ["PagePaginationMetadata" , " SyncPage" , "AsyncPage" ]
11
11
12
12
13
13
class PagePaginationMetadata (BaseModel ):
@@ -22,15 +22,20 @@ class SyncPage(BaseSyncPage[ModelT], BasePage[ModelT], Generic[ModelT]):
22
22
23
23
@override
24
24
def _get_page_items (self ) -> List [ModelT ]:
25
- return self .data
25
+ data = self .data
26
+ if not data :
27
+ return []
28
+ return data
26
29
27
30
@override
28
31
def next_page_info (self ) -> Optional [PageInfo ]:
29
- cursor = self .pagination_metadata .next_cursor
30
- if not cursor :
32
+ next_cursor = None
33
+ if self .pagination_metadata is not None : # pyright: ignore[reportUnnecessaryComparison]
34
+ next_cursor = self .pagination_metadata .next_cursor
35
+ if not next_cursor :
31
36
return None
32
37
33
- return PageInfo (params = {"cursor" : cursor })
38
+ return PageInfo (params = {"cursor" : next_cursor })
34
39
35
40
36
41
class AsyncPage (BaseAsyncPage [ModelT ], BasePage [ModelT ], Generic [ModelT ]):
@@ -39,12 +44,17 @@ class AsyncPage(BaseAsyncPage[ModelT], BasePage[ModelT], Generic[ModelT]):
39
44
40
45
@override
41
46
def _get_page_items (self ) -> List [ModelT ]:
42
- return self .data
47
+ data = self .data
48
+ if not data :
49
+ return []
50
+ return data
43
51
44
52
@override
45
53
def next_page_info (self ) -> Optional [PageInfo ]:
46
- cursor = self .pagination_metadata .next_cursor
47
- if not cursor :
54
+ next_cursor = None
55
+ if self .pagination_metadata is not None : # pyright: ignore[reportUnnecessaryComparison]
56
+ next_cursor = self .pagination_metadata .next_cursor
57
+ if not next_cursor :
48
58
return None
49
59
50
- return PageInfo (params = {"cursor" : cursor })
60
+ return PageInfo (params = {"cursor" : next_cursor })
0 commit comments