Skip to content

Commit

Permalink
Merge pull request ucfopen#677 from handcartcactus/issue/676-improve-…
Browse files Browse the repository at this point in the history
…developer-experience

Issue ucfopen#676 Improve developer experience
  • Loading branch information
HandcartCactus authored Dec 27, 2024
1 parent e9154d2 commit 45ba5ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- Deundre Williams [@deundrewilliams](https://github.com/deundrewilliams)
- Devin Singh [@devints47](https://github.com/devints47)
- Dmitry Savransky [@dsavransky](https://github.com/dsavransky)
- Elias [@HandcartCactus](https://github.com/HandcartCactus)
- Elise Heron [@thedarkestknight](https://github.com/thedarkestknight)
- Elli Howard [@qwertynerd97](https://github.com/qwertynerd97)
- Erik Tews [@eriktews](https://github.com/eriktews)
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Backstage

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

## [3.3.0] - 2023-08-27

Expand Down
13 changes: 9 additions & 4 deletions canvasapi/paginated_list.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from __future__ import annotations

import re
from typing import Iterable, Iterator, Type, TypeVar

T = TypeVar("T")


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

def __init__(
self,
content_class,
content_class: Type[T],
requester,
request_method,
first_url,
extra_attribs=None,
_root=None,
_url_override=None,
**kwargs
**kwargs,
):
"""
:param content_class: The expected type to return in the list.
Expand Down Expand Up @@ -60,7 +65,7 @@ def __init__(
self._root = _root
self._url_override = _url_override

def __iter__(self):
def __iter__(self) -> Iterator[T]:
for element in self._elements:
yield element
while self._has_next():
Expand Down

0 comments on commit 45ba5ac

Please sign in to comment.