Correctly deal when PaginatedList's data is a dict (#2084)

When calculating totalCount for a PaginatedList, if a Link header is not
in the returned data, we use len() to calculate the number of items.
PullRequest.get_review_requests() actually returns a dictionary, which
neatly defeats this naive method. Peer inside the dictionary in this
case, and add a test case.

Fixes #2053
This commit is contained in:
Steve Kowalik
2021-10-20 18:49:12 +11:00
committed by GitHub
parent 3f767649c8
commit 93b92cd2fc
3 changed files with 55 additions and 0 deletions
+2
View File
@@ -153,6 +153,8 @@ class PaginatedList(PaginatedListBase):
if data and "total_count" in data:
self.__totalCount = data["total_count"]
elif data:
if isinstance(data, dict):
data = data[self.__list_item]
self.__totalCount = len(data)
else:
self.__totalCount = 0