Skip to content

Commit 115938b

Browse files
feat: add support for lists of integers to ListAttribute
Previously ListAttribute only support lists of integers. Now be more flexible and support lists of items which can be coerced into strings, for example integers. This will help us fix issue #1407 by using ListAttribute for the 'iids' field.
1 parent e37de18 commit 115938b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

gitlab/tests/test_types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ def test_list_attribute_get_for_api_from_list():
5959
assert o.get_for_api() == "foo,bar,baz"
6060

6161

62+
def test_list_attribute_get_for_api_from_int_list():
63+
o = types.ListAttribute([1, 9, 7])
64+
assert o.get_for_api() == "1,9,7"
65+
66+
6267
def test_list_attribute_does_not_split_string():
6368
o = types.ListAttribute("foo")
6469
assert o.get_for_api() == "foo"

gitlab/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_for_api(self):
4242
if isinstance(self._value, str):
4343
return self._value
4444

45-
return ",".join(self._value)
45+
return ",".join([str(x) for x in self._value])
4646

4747

4848
class LowercaseStringAttribute(GitlabAttribute):

0 commit comments

Comments
 (0)