Skip to content

Calling list() with Iterator leads to warnings #2798

@cweber-dbs

Description

@cweber-dbs

Description of the problem, including code/CLI snippet

We are using the list operation for our commits using an iterator:

    def create(self) -> None:
        self._logger.info("Analysing the git history...")
        self._analyse_commits(
            iterator=self._gitlab_project.commits.list(
                ref_name=self._ref_name, iterator=True,
            ),
            identifier=self._ref_name,
        )
        
        def _analyse_commits(self, identifier: str, iterator: Iterator):
        while True:
            try:
                commit = iterator.next()
            except StopIteration:
                self._logger.info(f"No more commits for '{identifier}'")
                return

            # Do some stuff with commit

Expected Behavior

No Warnings occur

Actual Behavior

Several Warnings occur counting up from 21 to 241 (or even more if there are more commits) items (marked as xxx in the warning):

UserWarning: Calling alist()method without specifyingget_all=Trueoriterator=Truewill return a maximum of 20 items. Your query returned 20 of xxx items. See https://python-gitlab.readthedocs.io/en/v4.4.0/api-usage.html#pagination for more details. If this was done intentionally, then this warning can be supressed by adding the argumentget_all=Falseto thelist()call.

Specifications

  • python-gitlab version: 4.4.0
  • API version you are using (v3/v4): ?
  • Gitlab server version (or gitlab.com): v16.8.1-ee

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