reupen / aiogithub

asyncio-based GitHub API client

Home Page:https://aiogithub.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simplify API for paginated objects

reupen opened this issue · comments

Roughly speaking, so:

        # Get this user's repos
        repos = await user.get_repos()
        # There's no need to worry about pagination – you can simply iterate 
        # over list objects like this and pages will be retrieved as needed:
        async for repo in repos:
            pass # Do something with each repo here

becomes:

        # Get this user's repos
        # There's no need to worry about pagination – you can simply iterate 
        # over list objects like this and pages will be retrieved as needed:
        async for repo in user.get_repos():
            pass # Do something with each repo here

And:

        # Or you can fetch the entire list like this:
        repos = await user.get_repos()
        all_repos = await repos.get_all()
        # Do something with all_repos 

becomes:

        # Or you can fetch the entire list like this:
        repos = await user.get_repos().all()
        # Do something with all_repos