@@ -163,7 +163,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
163
163
164
164
@cli .register_custom_action ("User" )
165
165
@exc .on_http_error (exc .GitlabBlockError )
166
- def block (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
166
+ def block (self , ** kwargs : Any ) -> bool :
167
167
"""Block the user.
168
168
169
169
Args:
@@ -177,10 +177,13 @@ def block(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
177
177
Whether the user status has been changed
178
178
"""
179
179
path = f"/users/{ self .encoded_id } /block"
180
- server_data = self .manager .gitlab .http_post (path , ** kwargs )
181
- if server_data is True :
182
- self ._attrs ["state" ] = "blocked"
183
- return server_data
180
+ # NOTE: Undocumented behavior of the GitLab API is that it returns a boolean
181
+ server_data = cast (bool , self .manager .gitlab .http_post (path , ** kwargs ))
182
+ if isinstance (server_data , bool ):
183
+ if server_data is True :
184
+ self ._attrs ["state" ] = "blocked"
185
+ return server_data
186
+ return False
184
187
185
188
@cli .register_custom_action ("User" )
186
189
@exc .on_http_error (exc .GitlabFollowError )
@@ -220,7 +223,7 @@ def unfollow(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
220
223
221
224
@cli .register_custom_action ("User" )
222
225
@exc .on_http_error (exc .GitlabUnblockError )
223
- def unblock (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
226
+ def unblock (self , ** kwargs : Any ) -> bool :
224
227
"""Unblock the user.
225
228
226
229
Args:
@@ -234,10 +237,13 @@ def unblock(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
234
237
Whether the user status has been changed
235
238
"""
236
239
path = f"/users/{ self .encoded_id } /unblock"
237
- server_data = self .manager .gitlab .http_post (path , ** kwargs )
238
- if server_data is True :
239
- self ._attrs ["state" ] = "active"
240
- return server_data
240
+ # NOTE: Undocumented behavior of the GitLab API is that it returns a boolean
241
+ server_data = cast (bool , self .manager .gitlab .http_post (path , ** kwargs ))
242
+ if isinstance (server_data , bool ):
243
+ if server_data is True :
244
+ self ._attrs ["state" ] = "active"
245
+ return server_data
246
+ return False
241
247
242
248
@cli .register_custom_action ("User" )
243
249
@exc .on_http_error (exc .GitlabDeactivateError )
0 commit comments