@@ -530,7 +530,7 @@ class ApplicationSettingsManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
530
530
)
531
531
532
532
@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 ):
534
534
"""Update an object on the server.
535
535
536
536
Args:
@@ -545,7 +545,7 @@ def update(self, id=None, new_data={}, **kwargs):
545
545
GitlabAuthenticationError: If authentication is not correct
546
546
GitlabUpdateError: If the server cannot perform the request
547
547
"""
548
-
548
+ new_data = new_data or {}
549
549
data = new_data .copy ()
550
550
if "domain_whitelist" in data and data ["domain_whitelist" ] is None :
551
551
data .pop ("domain_whitelist" )
@@ -865,13 +865,14 @@ class GroupLabelManager(ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTMa
865
865
_update_attrs = (("name" ,), ("new_name" , "color" , "description" , "priority" ))
866
866
867
867
# Update without ID.
868
- def update (self , name , new_data = {} , ** kwargs ):
868
+ def update (self , name , new_data = None , ** kwargs ):
869
869
"""Update a Label on the server.
870
870
871
871
Args:
872
872
name: The name of the label
873
873
**kwargs: Extra options to send to the server (e.g. sudo)
874
874
"""
875
+ new_data = new_data or {}
875
876
new_data ["name" ] = name
876
877
super ().update (id = None , new_data = new_data , ** kwargs )
877
878
@@ -2489,7 +2490,7 @@ class ProjectMergeRequestApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTMan
2489
2490
_update_uses_post = True
2490
2491
2491
2492
@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 ):
2493
2494
"""Change MR-level allowed approvers and approver groups.
2494
2495
2495
2496
Args:
@@ -2500,6 +2501,9 @@ def set_approvers(self, approver_ids=[], approver_group_ids=[], **kwargs):
2500
2501
GitlabAuthenticationError: If authentication is not correct
2501
2502
GitlabUpdateError: If the server failed to perform the request
2502
2503
"""
2504
+ approver_ids = approver_ids or []
2505
+ approver_group_ids = approver_group_ids or []
2506
+
2503
2507
path = "%s/%s/approvers" % (self ._parent .manager .path , self ._parent .get_id ())
2504
2508
data = {"approver_ids" : approver_ids , "approver_group_ids" : approver_group_ids }
2505
2509
self .gitlab .http_put (path , post_data = data , ** kwargs )
@@ -2994,13 +2998,14 @@ class ProjectLabelManager(
2994
2998
_update_attrs = (("name" ,), ("new_name" , "color" , "description" , "priority" ))
2995
2999
2996
3000
# Update without ID.
2997
- def update (self , name , new_data = {} , ** kwargs ):
3001
+ def update (self , name , new_data = None , ** kwargs ):
2998
3002
"""Update a Label on the server.
2999
3003
3000
3004
Args:
3001
3005
name: The name of the label
3002
3006
**kwargs: Extra options to send to the server (e.g. sudo)
3003
3007
"""
3008
+ new_data = new_data or {}
3004
3009
new_data ["name" ] = name
3005
3010
super ().update (id = None , new_data = new_data , ** kwargs )
3006
3011
@@ -3130,7 +3135,7 @@ def create(self, data, **kwargs):
3130
3135
return self ._obj_cls (self , server_data )
3131
3136
3132
3137
@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 ):
3134
3139
"""Update an object on the server.
3135
3140
3136
3141
Args:
@@ -3145,7 +3150,7 @@ def update(self, file_path, new_data={}, **kwargs):
3145
3150
GitlabAuthenticationError: If authentication is not correct
3146
3151
GitlabUpdateError: If the server cannot perform the request
3147
3152
"""
3148
-
3153
+ new_data = new_data or {}
3149
3154
data = new_data .copy ()
3150
3155
file_path = file_path .replace ("/" , "%2F" )
3151
3156
data ["file_path" ] = file_path
@@ -3632,7 +3637,7 @@ def get(self, id, **kwargs):
3632
3637
obj .id = id
3633
3638
return obj
3634
3639
3635
- def update (self , id = None , new_data = {} , ** kwargs ):
3640
+ def update (self , id = None , new_data = None , ** kwargs ):
3636
3641
"""Update an object on the server.
3637
3642
3638
3643
Args:
@@ -3647,6 +3652,7 @@ def update(self, id=None, new_data={}, **kwargs):
3647
3652
GitlabAuthenticationError: If authentication is not correct
3648
3653
GitlabUpdateError: If the server cannot perform the request
3649
3654
"""
3655
+ new_data = new_data or {}
3650
3656
super (ProjectServiceManager , self ).update (id , new_data , ** kwargs )
3651
3657
self .id = id
3652
3658
@@ -3689,7 +3695,7 @@ class ProjectApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
3689
3695
_update_uses_post = True
3690
3696
3691
3697
@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 ):
3693
3699
"""Change project-level allowed approvers and approver groups.
3694
3700
3695
3701
Args:
@@ -3700,6 +3706,8 @@ def set_approvers(self, approver_ids=[], approver_group_ids=[], **kwargs):
3700
3706
GitlabAuthenticationError: If authentication is not correct
3701
3707
GitlabUpdateError: If the server failed to perform the request
3702
3708
"""
3709
+ approver_ids = approver_ids or []
3710
+ approver_group_ids = approver_group_ids or []
3703
3711
3704
3712
path = "/projects/%s/approvers" % self ._parent .get_id ()
3705
3713
data = {"approver_ids" : approver_ids , "approver_group_ids" : approver_group_ids }
@@ -4182,7 +4190,7 @@ def unshare(self, group_id, **kwargs):
4182
4190
# variables not supported in CLI
4183
4191
@cli .register_custom_action ("Project" , ("ref" , "token" ))
4184
4192
@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 ):
4186
4194
"""Trigger a CI build.
4187
4195
4188
4196
See https://gitlab.com/help/ci/triggers/README.md#trigger-a-build
@@ -4197,6 +4205,7 @@ def trigger_pipeline(self, ref, token, variables={}, **kwargs):
4197
4205
GitlabAuthenticationError: If authentication is not correct
4198
4206
GitlabCreateError: If the server failed to perform the request
4199
4207
"""
4208
+ variables = variables or {}
4200
4209
path = "/projects/%s/trigger/pipeline" % self .get_id ()
4201
4210
post_data = {"ref" : ref , "token" : token , "variables" : variables }
4202
4211
attrs = self .manager .gitlab .http_post (path , post_data = post_data , ** kwargs )
0 commit comments