Skip to content

Regression on calling len() on GitlabList objects since switching to keyset pagination by default #1114

@Lucas-C

Description

@Lucas-C

Description of the problem, including code/CLI snippet

Pull request #1110 that has been released in v2.3.0 yesterday introduced a regression on a specific scenario:
when calling len() on the output of Gitlab().projects.list(as_list=False).

Expected Behavior

Being able to call len() on the iterator returned by Gitlab().projects.list(as_list=False)

Actual Behavior

Minimal reproduction code:

import gitlab
len(gitlab.Gitlab(...).projects.list(as_list=False))

Output:

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    len(gitlab.Gitlab(...).projects.list(as_list=False))#, pagination='offset'))
  File ".../lib/python3.7/site-packages/gitlab/base.py", line 184, in __len__
    return len(self._list)
  File ".../lib/python3.7/site-packages/gitlab/__init__.py", line 863, in __len__
    return int(self._total)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Workaround:

import gitlab
len(gitlab.Gitlab(...).projects.list(as_list=False, pagination='offset'))

Specifications

  • python-gitlab version: sicnce v2.3.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 12.10.7-ee (80b99e43cfc)

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy