File tree 3 files changed +25
-10
lines changed
3 files changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -265,8 +265,17 @@ The generator exposes extra listing information as received from the server:
265
265
* ``prev_page ``: if ``None `` the current page is the first one
266
266
* ``next_page ``: if ``None `` the current page is the last one
267
267
* ``per_page ``: number of items per page
268
- * ``total_pages ``: total number of pages available
269
- * ``total ``: total number of items in the list
268
+ * ``total_pages ``: total number of pages available. This may be a ``None `` value.
269
+ * ``total ``: total number of items in the list. This may be a ``None `` value.
270
+
271
+ .. note ::
272
+
273
+ ``total_pages `` and ``total `` may have a value of ``None ``. For performance
274
+ reasons, if a query returns more than 10,000 records, GitLab doesn’t return
275
+ any value for ``total_pages `` or ``total ``.
276
+
277
+ For more information see:
278
+ https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
270
279
271
280
Sudo
272
281
====
Original file line number Diff line number Diff line change @@ -288,12 +288,12 @@ def per_page(self) -> int:
288
288
return self ._list .per_page
289
289
290
290
@property
291
- def total_pages (self ) -> int :
291
+ def total_pages (self ) -> Optional [ int ] :
292
292
"""The total number of pages."""
293
293
return self ._list .total_pages
294
294
295
295
@property
296
- def total (self ) -> int :
296
+ def total (self ) -> Optional [ int ] :
297
297
"""The total number of items."""
298
298
return self ._list .total
299
299
Original file line number Diff line number Diff line change @@ -966,17 +966,23 @@ def per_page(self) -> int:
966
966
return int (self ._per_page )
967
967
968
968
@property
969
- def total_pages (self ) -> int :
969
+ def total_pages (self ) -> Optional [ int ] :
970
970
"""The total number of pages."""
971
- if TYPE_CHECKING :
972
- assert self ._total_pages is not None
971
+ if self ._total_pages is None :
972
+ # NOTE(jlvillal): When a query returns more than 10,000 items, GitLab
973
+ # doesn't return the header for this value. So we return None.
974
+ # https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
975
+ return None
973
976
return int (self ._total_pages )
974
977
975
978
@property
976
- def total (self ) -> int :
979
+ def total (self ) -> Optional [ int ] :
977
980
"""The total number of items."""
978
- if TYPE_CHECKING :
979
- assert self ._total is not None
981
+ if self ._total is None :
982
+ # NOTE(jlvillal): When a query returns more than 10,000 items, GitLab
983
+ # doesn't return the header for this value. So we return None.
984
+ # https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
985
+ return None
980
986
return int (self ._total )
981
987
982
988
def __iter__ (self ) -> "GitlabList" :
You can’t perform that action at this time.
0 commit comments