Skip to content

Commit 45ba5ac

Browse files
Merge pull request #677 from handcartcactus/issue/676-improve-developer-experience
Issue #676 Improve developer experience
1 parent e9154d2 commit 45ba5ac

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
- Deundre Williams [@deundrewilliams](https://github.com/deundrewilliams)
4343
- Devin Singh [@devints47](https://github.com/devints47)
4444
- Dmitry Savransky [@dsavransky](https://github.com/dsavransky)
45+
- Elias [@HandcartCactus](https://github.com/HandcartCactus)
4546
- Elise Heron [@thedarkestknight](https://github.com/thedarkestknight)
4647
- Elli Howard [@qwertynerd97](https://github.com/qwertynerd97)
4748
- Erik Tews [@eriktews](https://github.com/eriktews)

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Backstage
1010

1111
- Updated deploy Action to use more modern processes.
12+
- Updated `PaginatedList` to be type-aware, showing which class is included in the response. (Thanks [@HandcartCactus](https://github.com/HandcartCactus))
1213

1314
## [3.3.0] - 2023-08-27
1415

canvasapi/paginated_list.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
from __future__ import annotations
2+
13
import re
4+
from typing import Iterable, Iterator, Type, TypeVar
5+
6+
T = TypeVar("T")
27

38

4-
class PaginatedList(object):
9+
class PaginatedList(Iterable[T]):
510
"""
611
Abstracts `pagination of Canvas API \
712
<https://canvas.instructure.com/doc/api/file.pagination.html>`_.
@@ -19,14 +24,14 @@ def __getitem__(self, index):
1924

2025
def __init__(
2126
self,
22-
content_class,
27+
content_class: Type[T],
2328
requester,
2429
request_method,
2530
first_url,
2631
extra_attribs=None,
2732
_root=None,
2833
_url_override=None,
29-
**kwargs
34+
**kwargs,
3035
):
3136
"""
3237
:param content_class: The expected type to return in the list.
@@ -60,7 +65,7 @@ def __init__(
6065
self._root = _root
6166
self._url_override = _url_override
6267

63-
def __iter__(self):
68+
def __iter__(self) -> Iterator[T]:
6469
for element in self._elements:
6570
yield element
6671
while self._has_next():

0 commit comments

Comments
 (0)