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

Commit7753fa2

Browse files
authored
Merge pull request#1515 from JohnVillalovos/jlvillal/mypy_v4_obj_users
chore: add type-hints to gitlab/v4/objects/users.py
2 parents9656a16 +88988e3 commit7753fa2

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

‎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:

‎pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ ignore_errors = true
2323

2424
[[tool.mypy.overrides]]# Overrides to negate above patterns
2525
module = [
26-
"gitlab.v4.objects.projects"
26+
"gitlab.v4.objects.projects",
27+
"gitlab.v4.objects.users"
2728
]
2829
ignore_errors =false
2930

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp