diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2021-10-06 21:19:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-06 21:19:49 +0200 |
commit | 7753fa2dd009a12ceac47f4444c9a43a83bb53a9 (patch) | |
tree | 32af17e9032aed2fb3fa2012758f3a76ffc46c76 | |
parent | 9656a16f9f34a1aeb8ea0015564bad68ffb39c26 (diff) | |
parent | 88988e3059ebadd3d1752db60c2d15b7e60e7c46 (diff) | |
download | gitlab-7753fa2dd009a12ceac47f4444c9a43a83bb53a9.tar.gz |
Merge pull request #1515 from JohnVillalovos/jlvillal/mypy_v4_obj_users
chore: add type-hints to gitlab/v4/objects/users.py
-rw-r--r-- | gitlab/v4/objects/users.py | 23 | ||||
-rw-r--r-- | pyproject.toml | 3 |
2 files changed, 17 insertions, 9 deletions
diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py index 63da837..e4bbcf1 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: diff --git a/pyproject.toml b/pyproject.toml index 0d13f24..a924199 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,8 @@ ignore_errors = true [[tool.mypy.overrides]] # Overrides to negate above patterns module = [ - "gitlab.v4.objects.projects" + "gitlab.v4.objects.projects", + "gitlab.v4.objects.users" ] ignore_errors = false |