33https://docs.gitlab.com/ee/api/users.html
44https://docs.gitlab.com/ee/api/projects.html#list-projects-starred-by-a-user
55"""
6- from typing import Any ,cast ,Dict ,List ,Union
6+ from typing import Any ,cast ,Dict ,List ,Optional , Union
77
88import requests
99
@@ -163,7 +163,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
163163
164164@cli .register_custom_action ("User" )
165165@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 ]:
167167"""Block the user.
168168
169169 Args:
@@ -177,7 +177,11 @@ def block(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
177177 Whether the user status has been changed
178178 """
179179path = 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+ )
181185if server_data is True :
182186self ._attrs ["state" ]= "blocked"
183187return server_data
@@ -220,7 +224,7 @@ def unfollow(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
220224
221225@cli .register_custom_action ("User" )
222226@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 ]:
224228"""Unblock the user.
225229
226230 Args:
@@ -234,7 +238,11 @@ def unblock(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
234238 Whether the user status has been changed
235239 """
236240path = 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+ )
238246if server_data is True :
239247self ._attrs ["state" ]= "active"
240248return server_data