Skip to content

Pagination generator with non-default per_page #405

@ericfrederich

Description

@ericfrederich

Currently if you request `xxx.list(as_list=False, per_page=100) you end up getting a list instead of the generator.

I think the logic in in http_list needs some rework.
Perhaps just removing the 'per_page' in kwargs condition from here

I should be able to specify something like...

my_generator = gl.projects.list(per_page=100, as_list=False)

... and still get a generator. Then I can hook it up to a progress bar like:

my_generator = gl.projects.list(per_page=100, as_list=False, membership=True)
with click.progressbar(my_generator, length=my_generator.total, label='Projects') as bar:
    for project in bar:
        pass

The above code generates the following error:

AttributeError: 'list' object has no attribute 'total'

Today if I want to use the generator function I have to leave the per_page off and get them only 20 at a time; this makes it much slower.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions