1+ from typing import Any , cast , Dict , List , Union
2+
3+ import requests
4+
15from gitlab import cli
26from gitlab import exceptions as exc
37from gitlab import types
4- from gitlab .base import RequiredOptional , RESTManager , RESTObject
8+ from gitlab .base import RequiredOptional , RESTManager , RESTObject , RESTObjectList
59from gitlab .mixins import (
610 CreateMixin ,
711 CRUDMixin ,
@@ -129,7 +133,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
129133
130134 @cli .register_custom_action ("User" )
131135 @exc .on_http_error (exc .GitlabBlockError )
132- def block (self , ** kwargs ) :
136+ def block (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
133137 """Block the user.
134138
135139 Args:
@@ -150,7 +154,7 @@ def block(self, **kwargs):
150154
151155 @cli .register_custom_action ("User" )
152156 @exc .on_http_error (exc .GitlabFollowError )
153- def follow (self , ** kwargs ) :
157+ def follow (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
154158 """Follow the user.
155159
156160 Args:
@@ -168,7 +172,7 @@ def follow(self, **kwargs):
168172
169173 @cli .register_custom_action ("User" )
170174 @exc .on_http_error (exc .GitlabUnfollowError )
171- def unfollow (self , ** kwargs ) :
175+ def unfollow (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
172176 """Unfollow the user.
173177
174178 Args:
@@ -186,7 +190,7 @@ def unfollow(self, **kwargs):
186190
187191 @cli .register_custom_action ("User" )
188192 @exc .on_http_error (exc .GitlabUnblockError )
189- def unblock (self , ** kwargs ) :
193+ def unblock (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
190194 """Unblock the user.
191195
192196 Args:
@@ -207,7 +211,7 @@ def unblock(self, **kwargs):
207211
208212 @cli .register_custom_action ("User" )
209213 @exc .on_http_error (exc .GitlabDeactivateError )
210- def deactivate (self , ** kwargs ) :
214+ def deactivate (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
211215 """Deactivate the user.
212216
213217 Args:
@@ -228,7 +232,7 @@ def deactivate(self, **kwargs):
228232
229233 @cli .register_custom_action ("User" )
230234 @exc .on_http_error (exc .GitlabActivateError )
231- def activate (self , ** kwargs ) :
235+ def activate (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
232236 """Activate the user.
233237
234238 Args:
@@ -319,6 +323,9 @@ class UserManager(CRUDMixin, RESTManager):
319323 )
320324 _types = {"confirm" : types .LowercaseStringAttribute , "avatar" : types .ImageAttribute }
321325
326+ def get (self , id : Union [str , int ], lazy : bool = False , ** kwargs : Any ) -> User :
327+ return cast (User , super ().get (id = id , lazy = lazy , ** kwargs ))
328+
322329
323330class ProjectUser (RESTObject ):
324331 pass
@@ -470,7 +477,7 @@ class UserProjectManager(ListMixin, CreateMixin, RESTManager):
470477 "id_before" ,
471478 )
472479
473- def list (self , ** kwargs ) :
480+ def list (self , ** kwargs : Any ) -> Union [ RESTObjectList , List [ RESTObject ]] :
474481 """Retrieve a list of objects.
475482
476483 Args:
0 commit comments