fastai / ghapi

A delightful and complete interface to GitHub's amazing API
https://ghapi.fast.ai/
Apache License 2.0
526 stars 57 forks source link

Pagination Broke. ghapi 1.0.3 #163

Closed yourcodeishotgarbage closed 3 months ago

yourcodeishotgarbage commented 1 year ago

Python 3.9.17 ghapi 1.0.3

No pagination, works fine

repos = api.repos.list_for_org(org=GITHUB_USER_OR_ORG,per_page=100)
print(len(repos),repos[0].name)

Output: 100 myrepo

With pagination:

repos = paged(api.repos.list_for_org(org=GITHUB_USER_OR_ORG,per_page=100))
print(len(repos),repos[0].name)

Output: TypeError: object of type 'generator' has no len()

I also do not see anywhere in the documentation to use: from ghapi.page import paged I had to find it on some other random example.

You would have thought from ghapi.all import GhApi implies ALL but silly me.

jph00 commented 3 months ago

A generator in python doesn't have a length. Wrap it in list if you want it's length. To import all symbols from a module, use from module import *.