3
3
https://docs.gitlab.com/ee/api/users.html
4
4
https://docs.gitlab.com/ee/api/projects.html#list-projects-starred-by-a-user
5
5
"""
6
- from typing import Any , cast , Dict , List , Union
6
+ from typing import Any , cast , Dict , List , Optional , Union
7
7
8
8
import requests
9
9
@@ -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 ) -> Optional [ bool ]:
167
167
"""Block the user.
168
168
169
169
Args:
@@ -177,7 +177,11 @@ 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 )
180
+ # NOTE: Undocumented behavior of the GitLab API is that it returns a
181
+ # boolean or None
182
+ server_data = cast (
183
+ Optional [bool ], self .manager .gitlab .http_post (path , ** kwargs )
184
+ )
181
185
if server_data is True :
182
186
self ._attrs ["state" ] = "blocked"
183
187
return server_data
@@ -220,7 +224,7 @@ def unfollow(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
220
224
221
225
@cli .register_custom_action ("User" )
222
226
@exc .on_http_error (exc .GitlabUnblockError )
223
- def unblock (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ]:
227
+ def unblock (self , ** kwargs : Any ) -> Optional [ bool ]:
224
228
"""Unblock the user.
225
229
226
230
Args:
@@ -234,7 +238,11 @@ def unblock(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
234
238
Whether the user status has been changed
235
239
"""
236
240
path = f"/users/{ self .encoded_id } /unblock"
237
- server_data = self .manager .gitlab .http_post (path , ** kwargs )
241
+ # NOTE: Undocumented behavior of the GitLab API is that it returns a
242
+ # boolean or None
243
+ server_data = cast (
244
+ Optional [bool ], self .manager .gitlab .http_post (path , ** kwargs )
245
+ )
238
246
if server_data is True :
239
247
self ._attrs ["state" ] = "active"
240
248
return server_data
0 commit comments