10000 chore: correct type-hints for per_page attrbute · python-gitlab/python-gitlab@447cac5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 447cac5

Browse files
chore: correct type-hints for per_page attrbute
There are occasions where a GitLab `list()` call does not return the `x-per-page` header. For example the listing of custom attributes. Update the type-hints to reflect that.
1 parent 2fea2e6 commit 447cac5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

gitlab/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def next_page(self) -> Optional[int]:
302302
return self._list.next_page
303303

304304
@property
305-
def per_page(self) -> int:
305+
def per_page(self) -> Optional[int]:
306306
"""The number of items per page."""
307307
return self._list.per_page
308308

gitlab/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,10 +1039,10 @@ def next_page(self) -> Optional[int]:
10391039
return int(self._next_page) if self._next_page else None
10401040

10411041
@property
1042-
def per_page(self) -> int:
1042+
def per_page(self) -> Optional[int]:
10431043
"""The number of items per page."""
1044-
if TYPE_CHECKING:
1045-
assert self._per_page is not None
1044+
if self._per_page is None:
1045+
return None
10461046
return int(self._per_page)
10471047

10481048
# NOTE(jlvillal): When a query returns more than 10,000 items, GitLab doesn't return

0 commit comments

Comments
 (0)
0