MCPcopy
hub / github.com/PyGithub/PyGithub / PaginatedList

Class PaginatedList

github/PaginatedList.py:143–494  ·  view source on GitHub ↗

This class abstracts the `pagination of the REST API `_ and the `GraphQl API `_. You can simply enumerate through instances of this class::

Source from the content-addressed store, hash-verified

141
142
143class PaginatedList(PaginatedListBase[T]):
144 """
145 This class abstracts the `pagination of the REST API <https://docs.github.com/en/rest/guides/traversing-with-pagination>`_
146 and the `GraphQl API <https://docs.github.com/en/graphql/guides/using-pagination-in-the-graphql-api>`_.
147
148 You can simply enumerate through instances of this class::
149
150 for repo in user.get_repos():
151 print(repo.name)
152
153 If you want to know the total number of items in the list::
154
155 print(user.get_repos().totalCount)
156
157 You can also index them or take slices::
158
159 second_repo = user.get_repos()[1]
160 first_repos = user.get_repos()[:10]
161
162 If you want to iterate in reversed order, just do::
163
164 for repo in reversed(user.get_repos()):
165 print(repo.name)
166
167 And if you really need it, you can explicitly access a specific page::
168
169 repos = user.get_repos()
170 assert repos.is_rest, "get_page not supported by the GraphQL API"
171
172 some_repos = repos.get_page(0)
173 some_other_repos = repos.get_page(3)
174
175 Individual items of this list are fetched in pages. The size of those pages
176 is configured via ``per_page`` when creating the :class:`github.MainClass.Github` instance::
177
178 g = github.Github(per_page=100)
179
180 The default page size is 30. The maximum page size is usually 100.
181
182 Paginated lists are returned by ``get_…`` methods. Additionally, some classes have one property
183 that is a paginated list, called `paginated property <https://pygithub.readthedocs.io/en/stable/utilities.html#classes-with-paginated-properties>`_.
184
185 """
186
187 # v3: move * before firstUrl and fix call sites
188 def __init__(
189 self,
190 contentClass: type[T],
191 requester: Requester,
192 firstUrl: str | None = None,
193 firstParams: dict[str, Any] | None = None,
194 *,
195 headers: dict[str, str] | None = None,
196 list_item: str | list[str] = "items",
197 total_count_item: str = "total_count",
198 firstData: Any | None = None,
199 firstHeaders: dict[str, str | int] | None = None,
200 attributesTransformer: Callable[[dict[str, Any]], dict[str, Any]] | None = None,

Callers 15

usersMethod · 0.90
get_usersMethod · 0.90
get_seatsMethod · 0.90
get_annotationsMethod · 0.90
get_check_runsMethod · 0.90
get_columnsMethod · 0.90
get_artifactsMethod · 0.90
jobsMethod · 0.90
selected_repositoriesMethod · 0.90
commitsMethod · 0.90
get_commitsMethod · 0.90
get_instancesMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…