Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99cee2a

Browse files
committed
feat: make deduplication optional
1 parent b7ac626 commit 99cee2a

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

gitlab/client.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,13 +1167,15 @@ def __init__(
11671167
url: str,
11681168
query_data: Dict[str, Any],
11691169
get_next: bool = True,
1170+
dedupe: bool = True,
11701171
**kwargs: Any,
11711172
) -> None:
11721173
self._gl = gl
11731174

11741175
# Preserve kwargs for subsequent queries
11751176
self._kwargs = kwargs.copy()
11761177

1178+
self._dedupe = dedupe
11771179
self._retrieved_object_ids: set[int] = set()
11781180

11791181
self._query(url, query_data, **self._kwargs)
@@ -1207,17 +1209,20 @@ def _query(
12071209
error_message="Failed to parse the server message"
12081210
) from e
12091211

1210-
duplicate_ids = set(o["id"] for o in self._data) & self._retrieved_object_ids
1211-
if duplicate_ids:
1212-
utils.warn(
1213-
message=(
1214-
f"During pagination duplicate object(s) with id(s) "
1215-
f"{duplicate_ids} returned from Gitlab and filtered"
1216-
),
1217-
category=UserWarning,
1212+
if self._dedupe:
1213+
duplicate_ids = (
1214+
set(o["id"] for o in self._data) & self._retrieved_object_ids
12181215
)
1219-
self._data = [o for o in self._data if o["id"] not in duplicate_ids]
1220-
self._retrieved_object_ids.update(o["id"] for o in self._data)
1216+
if duplicate_ids:
1217+
utils.warn(
1218+
message=(
1219+
f"During pagination duplicate object(s) with id(s) "
1220+
f"{duplicate_ids} returned from Gitlab and filtered"
1221+
),
1222+
category=UserWarning,
1223+
)
1224+
self._data = [o for o in self._data if o["id"] not in duplicate_ids]
1225+
self._retrieved_object_ids.update(o["id"] for o in self._data)
12211226

12221227
self._current = 0
12231228

0 commit comments

Comments
 (0)