Skip to content

Commit 9b6d89e

Browse files
JohnVillalovosnejch
authored andcommitted
refactor(list): as_list support is removed.
In `list()` calls support for the `as_list` argument has been removed. `as_list` was previously deprecated and now the use of `iterator` will be required if wanting to have same functionality as using `as_list` BREAKING CHANGE: Support for the deprecated `as_list` argument in `list()` calls has been removed. Use `iterator` instead.
1 parent 0b17a2d commit 9b6d89e

File tree

3 files changed

+0
-60
lines changed

3 files changed

+0
-60
lines changed

gitlab/client.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,6 @@ def http_list(
843843
path: str,
844844
query_data: Optional[Dict[str, Any]] = None,
845845
*,
846-
as_list: Optional[bool] = None, # Deprecated in favor of `iterator`
847846
iterator: Optional[bool] = None,
848847
**kwargs: Any,
849848
) -> Union["GitlabList", List[Dict[str, Any]]]:
@@ -870,23 +869,6 @@ def http_list(
870869
"""
871870
query_data = query_data or {}
872871

873-
# Don't allow both `as_list` and `iterator` to be set.
874-
if as_list is not None and iterator is not None:
875-
raise ValueError(
876-
"Only one of `as_list` or `iterator` can be used. "
877-
"Use `iterator` instead of `as_list`. `as_list` is deprecated."
878-
)
879-
880-
if as_list is not None:
881-
iterator = not as_list
882-
utils.warn(
883-
message=(
884-
f"`as_list={as_list}` is deprecated and will be removed in a "
885-
f"future version. Use `iterator={iterator}` instead."
886-
),
887-
category=DeprecationWarning,
888-
)
889-
890872
# Provide a `get_all`` param to avoid clashes with `all` API attributes.
891873
get_all = kwargs.pop("get_all", None)
892874

@@ -900,8 +882,6 @@ def http_list(
900882

901883
if iterator and page is not None:
902884
arg_used_message = f"iterator={iterator}"
903-
if as_list is not None:
904-
arg_used_message = f"as_list={as_list}"
905885
utils.warn(
906886
message=(
907887
f"`{arg_used_message}` and `page={page}` were both specified. "

tests/functional/api/test_gitlab.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,3 @@ def test_list_iterator_true_nowarning(gl, recwarn):
282282
items = gl.gitlabciymls.list(iterator=True)
283283
assert not recwarn
284284
assert len(list(items)) > 20
285-
286-
287-
def test_list_as_list_false_warnings(gl):
288-
"""Using `as_list=False` will disable the UserWarning but cause a
289-
DeprecationWarning"""
290-
with pytest.warns(DeprecationWarning) as record:
291-
items = gl.gitlabciymls.list(as_list=False)
292-
assert len(record) == 1
293-
assert len(list(items)) > 20
294-
295-
296-
def test_list_with_as_list_and_iterator_raises(gl):
297-
with pytest.raises(ValueError, match="`as_list` or `iterator`"):
298-
gl.gitlabciymls.list(as_list=False, iterator=True)

tests/unit/test_gitlab_http_methods.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,6 @@ def test_list_request_page_and_iterator(gl):
556556
assert len(result) == 20
557557
assert len(responses.calls) == 1
558558

559-
with pytest.warns(
560-
UserWarning, match="`as_list=False` and `page=1` were both specified"
561-
):
562-
result = gl.http_list("/projects", as_list=False, page=1)
563-
assert isinstance(result, list)
564-
assert len(result) == 20
565-
assert len(responses.calls) == 2
566-
567559

568560
large_list_response = {
569561
"method": responses.GET,
@@ -596,24 +588,6 @@ def test_list_request_page_and_iterator(gl):
596588
}
597589

598590

599-
@responses.activate
600-
def test_as_list_deprecation_warning(gl):
601-
responses.add(**large_list_response)
602-
603-
with warnings.catch_warnings(record=True) as caught_warnings:
604-
result = gl.http_list("/projects", as_list=False)
605-
assert len(caught_warnings) == 1
606-
warning = caught_warnings[0]
607-
assert isinstance(warning.message, DeprecationWarning)
608-
message = str(warning.message)
609-
assert "`as_list=False` is deprecated" in message
610-
assert "Use `iterator=True` instead" in message
611-
assert __file__ == warning.filename
612-
assert not isinstance(result, list)
613-
assert len(list(result)) == 20
614-
assert len(responses.calls) == 1
615-
616-
617591
@responses.activate
618592
def test_list_request_pagination_warning(gl):
619593
responses.add(**large_list_response)

0 commit comments

Comments
 (0)