ucfopen / canvasapi

Python API wrapper for Instructure's Canvas LMS. Easily manage courses, users, gradebooks, and more.
https://pypi.python.org/pypi/canvasapi
MIT License
561 stars 175 forks source link

Issue/539 typed paginated list #656

Open bennettscience opened 5 months ago

bennettscience commented 5 months ago

Original PR (#539) from garth74:

This pull request makes two changes:

Adds type hinting to PaginatedList so that elements used in for-loops, list comprehensions, etc. are typed (more info). Adds negative indexing to PaginatedList.

Related Supports efforts of https://github.com/ucfopen/canvasapi/pull/435 and fixes https://github.com/ucfopen/canvasapi/issues/305 without preventing negative indexing all together (i.e., https://github.com/ucfopen/canvasapi/pull/306).

Updated to include upstream changes in develop since the original was opened in 2022.

bennettscience commented 5 months ago

I think there are two things worth discussing:

  1. The typing improvements will help. I think PaginatedList is one of the harder bits of the library to get right if you've never used it before. It might help users in more complex cases avoid gotchas.
  2. My concern is about negative indexing large lists. It still has to get all of the results before you can access the results. Should we (I?) put in some more effort to address the other related issues (see #114, #237, and #175.)