Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit51dd98b

Browse files
chore: add type-hints to gitlab/v4/objects/users.py
Adding type-hints to gitlab/v4/objects/users.py
1 parent85713bb commit51dd98b

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

‎.mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[mypy]
2-
files = gitlab/*.py,gitlab/v4/cli.py,gitlab/v4/objects/projects.py
2+
files = gitlab/*.py,gitlab/v4/cli.py,gitlab/v4/objects/projects.py,gitlab/v4/objects/users.py
33

44
# disallow_incomplete_defs: This flag reports an error whenever it encounters a
55
# partly annotated function definition.

‎gitlab/v4/objects/users.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
fromtypingimportAny,cast,Dict,List,Union
2+
3+
importrequests
4+
15
fromgitlabimportcli
26
fromgitlabimportexceptionsasexc
37
fromgitlabimporttypes
4-
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
8+
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject,RESTObjectList
59
fromgitlab.mixinsimport (
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-
defblock(self,**kwargs):
136+
defblock(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-
deffollow(self,**kwargs):
157+
deffollow(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-
defunfollow(self,**kwargs):
175+
defunfollow(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-
defunblock(self,**kwargs):
193+
defunblock(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-
defdeactivate(self,**kwargs):
214+
defdeactivate(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-
defactivate(self,**kwargs):
235+
defactivate(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+
defget(self,id:Union[str,int],lazy:bool=False,**kwargs:Any)->User:
327+
returncast(User,super().get(id=id,lazy=lazy,**kwargs))
328+
322329

323330
classProjectUser(RESTObject):
324331
pass
@@ -470,7 +477,7 @@ class UserProjectManager(ListMixin, CreateMixin, RESTManager):
470477
"id_before",
471478
)
472479

473-
deflist(self,**kwargs):
480+
deflist(self,**kwargs:Any)->Union[RESTObjectList,List[RESTObject]]:
474481
"""Retrieve a list of objects.
475482
476483
Args:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp