@@ -326,7 +326,7 @@ def reject(self, **kwargs: Any) -> gitlab.client.HttpResponseType:
326
326
327
327
@cli .register_custom_action ("User" )
328
328
@exc .on_http_error (exc .GitlabBanError )
329
- def ban (self , ** kwargs : Any ) -> gitlab . client . HttpResponseType :
329
+ def ban (self , ** kwargs : Any ) -> bool :
330
330
"""Ban the user.
331
331
332
332
Args:
@@ -340,14 +340,16 @@ def ban(self, **kwargs: Any) -> gitlab.client.HttpResponseType:
340
340
Whether the user has been banned
341
341
"""
342
342
path = f"/users/{ self .encoded_id } /ban"
343
- server_data = self .manager .gitlab .http_post (path , ** kwargs )
344
- if server_data :
343
+ # NOTE: Undocumented behavior of the GitLab API is that it returns True
344
+ # on success.
345
+ server_data = cast (bool , self .manager .gitlab .http_post (path , ** kwargs ))
346
+ if server_data is True :
345
347
self ._attrs ["state" ] = "banned"
346
348
return server_data
347
349
348
350
@cli .register_custom_action ("User" )
349
351
@exc .on_http_error (exc .GitlabUnbanError )
350
- def unban (self , ** kwargs : Any ) -> gitlab . client . HttpResponseType :
352
+ def unban (self , ** kwargs : Any ) -> bool :
351
353
"""Unban the user.
352
354
353
355
Args:
@@ -361,8 +363,10 @@ def unban(self, **kwargs: Any) -> gitlab.client.HttpResponseType:
361
363
Whether the user has been unbanned
362
364
"""
363
365
path = f"/users/{ self .encoded_id } /unban"
364
- server_data = self .manager .gitlab .http_post (path , ** kwargs )
365
- if server_data :
366
+ # NOTE: Undocumented behavior of the GitLab API is that it returns True
367
+ # on success.
368
+ server_data = cast (bool , self .manager .gitlab .http_post (path , ** kwargs ))
369
+ if server_data is True :
366
370
self ._attrs ["state" ] = "active"
367
371
return server_data
368
372
0 commit comments