Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a global setting to always get all element from list() calls #2843

Open
gdubicki opened this issue Apr 27, 2024 · 1 comment
Open

Comments

@gdubicki
Copy link

gdubicki commented Apr 27, 2024

Description of the problem

In the gitlabform app (https://github.com/gitlabform/gitlabform), and probably for many other purposes too, we always want to get all the elements of lists.

Current solution

There seem to be 2 options for that when using this library:

a) remember to use get_all=True and probably cause with increased resources use on the GitLab instance,

b) remember to use iterator=True and add extra code to get all the elements of the list,

Both of these require extra code that you need to remember about (because the missing parameter will not cause an error unless you test with lists of > 20 elements) and are inconvenient.

We already had 2 bugs in gitlabform because we forgot to add this code:

Proposed solution

Let's introduce a global configuration flag to get all the elements of each list by default.

We could name this flag get_all_by_default and pass it to the constructor (like the "pagination" parameter now).

This could be implemented with iterators to not cause an extra load in the GitLab instance. The execution time or resource use on the client side is less important here as this would probably be used for scripting, batch operations and generally non-interactive purposes.

Specifications

  • python-gitlab version: v4.4.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): doesn't matter
@nejch
Copy link
Member

nejch commented Apr 27, 2024

That's a cool idea @gdubicki! Even in my team we often end up creating something like a list_kwargs that we pass to all list methods. Having this natively would be nicer for sure.

It might be good to cover both the iterator and get_all for this, or just allow passing either of the two when instantiating the instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants