Skip to content

Commit 85757d8

Browse files
committed
fix: not re-implement inherited functions in ScopesListAttribute, add _types to objects
1 parent 02012ef commit 85757d8

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

gitlab/types.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,9 @@ def get_for_api(self):
4646

4747

4848
class ScopesListAttribute(ListAttribute):
49-
def set_from_cli(self, cli_value):
50-
if not cli_value.strip():
51-
self._value = []
52-
else:
53-
self._value = [item.strip() for item in cli_value.split(",")]
5449

5550
def get_for_api(self):
56-
# Do not comma-split single value passed as string
51+
# scopes are expected to be a list of strings
5752
if isinstance(self._value, str):
5853
return [self._value]
5954

gitlab/v4/objects/applications.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from gitlab.base import RESTManager, RESTObject
22
from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin
3+
from gitlab.types import ScopesListAttribute
34

45
__all__ = [
56
"Application",
@@ -16,3 +17,5 @@ class ApplicationManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
1617
_path = "/applications"
1718
_obj_cls = Application
1819
_create_attrs = (("name", "redirect_uri", "scopes"), ("confidential",))
20+
21+
_types = {"scopes": ScopesListAttribute}

gitlab/v4/objects/deploy_tokens.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from gitlab.base import RESTManager, RESTObject
22
from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin
3-
3+
from gitlab.types import ScopesListAttribute
44

55
__all__ = [
66
"DeployToken",
@@ -39,6 +39,7 @@ class GroupDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
3939
"username",
4040
),
4141
)
42+
_types = {"scopes": ScopesListAttribute}
4243

4344

4445
class ProjectDeployToken(ObjectDeleteMixin, RESTObject):
@@ -59,3 +60,4 @@ class ProjectDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager
5960
"username",
6061
),
6162
)
63+
_types = {"scopes": ScopesListAttribute}

gitlab/v4/objects/users.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
SaveMixin,
1414
UpdateMixin,
1515
)
16+
from gitlab.types import ScopesListAttribute
1617

1718
from .custom_attributes import UserCustomAttributeManager
1819
from .events import UserEventManager
@@ -406,6 +407,7 @@ class UserImpersonationTokenManager(NoUpdateMixin, RESTManager):
406407
_from_parent_attrs = {"user_id": "id"}
407408
_create_attrs = (("name", "scopes"), ("expires_at",))
408409
_list_filters = ("state",)
410+
_types = {"scopes": ScopesListAttribute}
409411

410412

411413
class UserMembership(RESTObject):

0 commit comments

Comments
 (0)