@@ -530,7 +530,7 @@ class ApplicationSettingsManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
530530 )
531531
532532 @exc .on_http_error (exc .GitlabUpdateError )
533- def update (self , id = None , new_data = {} , ** kwargs ):
533+ def update (self , id = None , new_data = None , ** kwargs ):
534534 """Update an object on the server.
535535
536536 Args:
@@ -545,7 +545,7 @@ def update(self, id=None, new_data={}, **kwargs):
545545 GitlabAuthenticationError: If authentication is not correct
546546 GitlabUpdateError: If the server cannot perform the request
547547 """
548-
548+ new_data = new_data or {}
549549 data = new_data .copy ()
550550 if "domain_whitelist" in data and data ["domain_whitelist" ] is None :
551551 data .pop ("domain_whitelist" )
@@ -865,13 +865,14 @@ class GroupLabelManager(ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTMa
865865 _update_attrs = (("name" ,), ("new_name" , "color" , "description" , "priority" ))
866866
867867 # Update without ID.
868- def update (self , name , new_data = {} , ** kwargs ):
868+ def update (self , name , new_data = None , ** kwargs ):
869869 """Update a Label on the server.
870870
871871 Args:
872872 name: The name of the label
873873 **kwargs: Extra options to send to the server (e.g. sudo)
874874 """
875+ new_data = new_data or {}
875876 new_data ["name" ] = name
876877 super ().update (id = None , new_data = new_data , ** kwargs )
877878
@@ -2489,7 +2490,7 @@ class ProjectMergeRequestApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTMan
24892490 _update_uses_post = True
24902491
24912492 @exc .on_http_error (exc .GitlabUpdateError )
2492- def set_approvers (self , approver_ids = [] , approver_group_ids = [] , ** kwargs ):
2493+ def set_approvers (self , approver_ids = None , approver_group_ids = None , ** kwargs ):
24932494 """Change MR-level allowed approvers and approver groups.
24942495
24952496 Args:
@@ -2500,6 +2501,9 @@ def set_approvers(self, approver_ids=[], approver_group_ids=[], **kwargs):
25002501 GitlabAuthenticationError: If authentication is not correct
25012502 GitlabUpdateError: If the server failed to perform the request
25022503 """
2504+ approver_ids = approver_ids or []
2505+ approver_group_ids = approver_group_ids or []
2506+
25032507 path = "%s/%s/approvers" % (self ._parent .manager .path , self ._parent .get_id ())
25042508 data = {"approver_ids" : approver_ids , "approver_group_ids" : approver_group_ids }
25052509 self .gitlab .http_put (path , post_data = data , ** kwargs )
@@ -2994,13 +2998,14 @@ class ProjectLabelManager(
29942998 _update_attrs = (("name" ,), ("new_name" , "color" , "description" , "priority" ))
29952999
29963000 # Update without ID.
2997- def update (self , name , new_data = {} , ** kwargs ):
3001+ def update (self , name , new_data = None , ** kwargs ):
29983002 """Update a Label on the server.
29993003
30003004 Args:
30013005 name: The name of the label
30023006 **kwargs: Extra options to send to the server (e.g. sudo)
30033007 """
3008+ new_data = new_data or {}
30043009 new_data ["name" ] = name
30053010 super ().update (id = None , new_data = new_data , ** kwargs )
30063011
@@ -3130,7 +3135,7 @@ def create(self, data, **kwargs):
31303135 return self ._obj_cls (self , server_data )
31313136
31323137 @exc .on_http_error (exc .GitlabUpdateError )
3133- def update (self , file_path , new_data = {} , ** kwargs ):
3138+ def update (self , file_path , new_data = None , ** kwargs ):
31343139 """Update an object on the server.
31353140
31363141 Args:
@@ -3145,7 +3150,7 @@ def update(self, file_path, new_data={}, **kwargs):
31453150 GitlabAuthenticationError: If authentication is not correct
31463151 GitlabUpdateError: If the server cannot perform the request
31473152 """
3148-
3153+ new_data = new_data or {}
31493154 data = new_data .copy ()
31503155 file_path = file_path .replace ("/" , "%2F" )
31513156 data ["file_path" ] = file_path
@@ -3632,7 +3637,7 @@ def get(self, id, **kwargs):
36323637 obj .id = id
36333638 return obj
36343639
3635- def update (self , id = None , new_data = {} , ** kwargs ):
3640+ def update (self , id = None , new_data = None , ** kwargs ):
36363641 """Update an object on the server.
36373642
36383643 Args:
@@ -3647,6 +3652,7 @@ def update(self, id=None, new_data={}, **kwargs):
36473652 GitlabAuthenticationError: If authentication is not correct
36483653 GitlabUpdateError: If the server cannot perform the request
36493654 """
3655+ new_data = new_data or {}
36503656 super (ProjectServiceManager , self ).update (id , new_data , ** kwargs )
36513657 self .id = id
36523658
@@ -3689,7 +3695,7 @@ class ProjectApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
36893695 _update_uses_post = True
36903696
36913697 @exc .on_http_error (exc .GitlabUpdateError )
3692- def set_approvers (self , approver_ids = [] , approver_group_ids = [] , ** kwargs ):
3698+ def set_approvers (self , approver_ids = None , approver_group_ids = None , ** kwargs ):
36933699 """Change project-level allowed approvers and approver groups.
36943700
36953701 Args:
@@ -3700,6 +3706,8 @@ def set_approvers(self, approver_ids=[], approver_group_ids=[], **kwargs):
37003706 GitlabAuthenticationError: If authentication is not correct
37013707 GitlabUpdateError: If the server failed to perform the request
37023708 """
3709+ approver_ids = approver_ids or []
3710+ approver_group_ids = approver_group_ids or []
37033711
37043712 path = "/projects/%s/approvers" % self ._parent .get_id ()
37053713 data = {"approver_ids" : approver_ids , "approver_group_ids" : approver_group_ids }
@@ -4182,7 +4190,7 @@ def unshare(self, group_id, **kwargs):
41824190 # variables not supported in CLI
41834191 @cli .register_custom_action ("Project" , ("ref" , "token" ))
41844192 @exc .on_http_error (exc .GitlabCreateError )
4185- def trigger_pipeline (self , ref , token , variables = {} , ** kwargs ):
4193+ def trigger_pipeline (self , ref , token , variables = None , ** kwargs ):
41864194 """Trigger a CI build.
41874195
41884196 See https://gitlab.com/help/ci/triggers/README.md#trigger-a-build
@@ -4197,6 +4205,7 @@ def trigger_pipeline(self, ref, token, variables={}, **kwargs):
41974205 GitlabAuthenticationError: If authentication is not correct
41984206 GitlabCreateError: If the server failed to perform the request
41994207 """
4208+ variables = variables or {}
42004209 path = "/projects/%s/trigger/pipeline" % self .get_id ()
42014210 post_data = {"ref" : ref , "token" : token , "variables" : variables }
42024211 attrs = self .manager .gitlab .http_post (path , post_data = post_data , ** kwargs )
0 commit comments