Skip to content

Commit 94e34d2

Browse files
Update based on review
1 parent c52f236 commit 94e34d2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

canvasapi/paginated_list.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,13 @@ def _get_next_page(self):
6363
# See https://github.com/ucfopen/canvasapi/discussions/605
6464
if response.links:
6565
next_link = response.links.get("next")
66-
elif type(data) is dict and data.get("meta") is not None:
66+
elif isinstance(data, dict) and "meta" in data:
6767
# requests parses headers into dicts, this returns the same
6868
# structure so the regex will still work.
69-
next_link = (
70-
{"url": data.get("meta").get("pagination").get("next"), "rel": "next"}
71-
if data["meta"]["pagination"]["next"]
72-
else None
73-
)
69+
try:
70+
next_link = {"url": data["meta"]["pagination"]["next"], "rel": "next"}
71+
except KeyError:
72+
next_link = None
7473
else:
7574
next_link = None
7675

0 commit comments

Comments
 (0)