1
+ from typing import Any , cast , Dict , List , Union
2
+
3
+ import requests
4
+
1
5
from gitlab import cli
2
6
from gitlab import exceptions as exc
3
7
from gitlab import types
4
- from gitlab .base import RequiredOptional , RESTManager , RESTObject
8
+ from gitlab .base import RequiredOptional , RESTManager , RESTObject , RESTObjectList
5
9
from gitlab .mixins import (
6
10
CreateMixin ,
7
11
CRUDMixin ,
@@ -129,7 +133,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
129
133
130
134
@cli .register_custom_action ("User" )
131
135
@exc .on_http_error (exc .GitlabBlockError )
132
- def block (self , ** kwargs ) :
136
+ def block (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
133
137
"""Block the user.
134
138
135
139
Args:
@@ -150,7 +154,7 @@ def block(self, **kwargs):
150
154
151
155
@cli .register_custom_action ("User" )
152
156
@exc .on_http_error (exc .GitlabFollowError )
153
- def follow (self , ** kwargs ) :
157
+ def follow (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
154
158
"""Follow the user.
155
159
156
160
Args:
@@ -168,7 +172,7 @@ def follow(self, **kwargs):
168
172
169
173
@cli .register_custom_action ("User" )
170
174
@exc .on_http_error (exc .GitlabUnfollowError )
171
- def unfollow (self , ** kwargs ) :
175
+ def unfollow (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
172
176
"""Unfollow the user.
173
177
174
178
Args:
@@ -186,7 +190,7 @@ def unfollow(self, **kwargs):
186
190
187
191
@cli .register_custom_action ("User" )
188
192
@exc .on_http_error (exc .GitlabUnblockError )
189
- def unblock (self , ** kwargs ) :
193
+ def unblock (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
190
194
"""Unblock the user.
191
195
192
196
Args:
@@ -207,7 +211,7 @@ def unblock(self, **kwargs):
207
211
208
212
@cli .register_custom_action ("User" )
209
213
@exc .on_http_error (exc .GitlabDeactivateError )
210
- def deactivate (self , ** kwargs ) :
214
+ def deactivate (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
211
215
"""Deactivate the user.
212
216
213
217
Args:
@@ -228,7 +232,7 @@ def deactivate(self, **kwargs):
228
232
229
233
@cli .register_custom_action ("User" )
230
234
@exc .on_http_error (exc .GitlabActivateError )
231
- def activate (self , ** kwargs ) :
235
+ def activate (self , ** kwargs : Any ) -> Union [ Dict [ str , Any ], requests . Response ] :
232
236
"""Activate the user.
233
237
234
238
Args:
@@ -319,6 +323,9 @@ class UserManager(CRUDMixin, RESTManager):
319
323
)
320
324
_types = {"confirm" : types .LowercaseStringAttribute , "avatar" : types .ImageAttribute }
321
325
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
+
322
329
323
330
class ProjectUser (RESTObject ):
324
331
pass
@@ -470,7 +477,7 @@ class UserProjectManager(ListMixin, CreateMixin, RESTManager):
470
477
"id_before" ,
471
478
)
472
479
473
- def list (self , ** kwargs ) :
480
+ def list (self , ** kwargs : Any ) -> Union [ RESTObjectList , List [ RESTObject ]] :
474
481
"""Retrieve a list of objects.
475
482
476
483
Args:
0 commit comments