summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2021-06-13 09:58:10 -0700
committerJohn L. Villalovos <john@sodarock.com>2021-09-07 08:22:20 -0700
commit88988e3059ebadd3d1752db60c2d15b7e60e7c46 (patch)
tree79764e5877c993c64e720dcfa367dbe35d8169bc /gitlab
parentb8a47bae3342400a411fb9bf4bef3c15ba91c98e (diff)
downloadgitlab-88988e3059ebadd3d1752db60c2d15b7e60e7c46.tar.gz
chore: add type-hints to gitlab/v4/objects/users.py
Adding type-hints to gitlab/v4/objects/users.py
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/v4/objects/users.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py
index cc5cfd8..9e5fd09 100644
--- a/gitlab/v4/objects/users.py
+++ b/gitlab/v4/objects/users.py
@@ -1,7 +1,11 @@
+from typing import Any, cast, Dict, List, Union
+
+import requests
+
from gitlab import cli
from gitlab import exceptions as exc
from gitlab import types
-from gitlab.base import RequiredOptional, RESTManager, RESTObject
+from gitlab.base import RequiredOptional, RESTManager, RESTObject, RESTObjectList
from gitlab.mixins import (
CreateMixin,
CRUDMixin,
@@ -129,7 +133,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
@cli.register_custom_action("User")
@exc.on_http_error(exc.GitlabBlockError)
- def block(self, **kwargs):
+ def block(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
"""Block the user.
Args:
@@ -150,7 +154,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
@cli.register_custom_action("User")
@exc.on_http_error(exc.GitlabFollowError)
- def follow(self, **kwargs):
+ def follow(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
"""Follow the user.
Args:
@@ -168,7 +172,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
@cli.register_custom_action("User")
@exc.on_http_error(exc.GitlabUnfollowError)
- def unfollow(self, **kwargs):
+ def unfollow(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
"""Unfollow the user.
Args:
@@ -186,7 +190,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
@cli.register_custom_action("User")
@exc.on_http_error(exc.GitlabUnblockError)
- def unblock(self, **kwargs):
+ def unblock(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
"""Unblock the user.
Args:
@@ -207,7 +211,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
@cli.register_custom_action("User")
@exc.on_http_error(exc.GitlabDeactivateError)
- def deactivate(self, **kwargs):
+ def deactivate(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
"""Deactivate the user.
Args:
@@ -228,7 +232,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
@cli.register_custom_action("User")
@exc.on_http_error(exc.GitlabActivateError)
- def activate(self, **kwargs):
+ def activate(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
"""Activate the user.
Args:
@@ -319,6 +323,9 @@ class UserManager(CRUDMixin, RESTManager):
)
_types = {"confirm": types.LowercaseStringAttribute, "avatar": types.ImageAttribute}
+ def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> User:
+ return cast(User, super().get(id=id, lazy=lazy, **kwargs))
+
class ProjectUser(RESTObject):
pass
@@ -470,7 +477,7 @@ class UserProjectManager(ListMixin, CreateMixin, RESTManager):
"id_before",
)
- def list(self, **kwargs):
+ def list(self, **kwargs: Any) -> Union[RESTObjectList, List[RESTObject]]:
"""Retrieve a list of objects.
Args: