summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-07-20 11:36:49 +0200
committerGitHub <noreply@github.com>2022-07-20 11:36:49 +0200
commitc84379d1c9a681516585dc077ec1a237468b4991 (patch)
treeed8a9952f39420444597fa431e3b278a6e31d14c /gitlab
parent5fc3216788342a2325662644b42e8c249b655ded (diff)
parenta29cd6ce1ff7fa7f31a386cea3e02aa9ba3fb6c2 (diff)
downloadgitlab-c84379d1c9a681516585dc077ec1a237468b4991.tar.gz
Merge pull request #2146 from python-gitlab/jlvillal/mypy_strict_step_by_step
chore: enable mypy check `strict_equality`
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/v4/objects/users.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py
index 69d72e9..69d875e 100644
--- a/gitlab/v4/objects/users.py
+++ b/gitlab/v4/objects/users.py
@@ -3,7 +3,7 @@ GitLab API:
https://docs.gitlab.com/ee/api/users.html
https://docs.gitlab.com/ee/api/projects.html#list-projects-starred-by-a-user
"""
-from typing import Any, cast, Dict, List, Union
+from typing import Any, cast, Dict, List, Optional, Union
import requests
@@ -163,7 +163,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
@cli.register_custom_action("User")
@exc.on_http_error(exc.GitlabBlockError)
- def block(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
+ def block(self, **kwargs: Any) -> Optional[bool]:
"""Block the user.
Args:
@@ -177,7 +177,11 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
Whether the user status has been changed
"""
path = f"/users/{self.encoded_id}/block"
- server_data = self.manager.gitlab.http_post(path, **kwargs)
+ # NOTE: Undocumented behavior of the GitLab API is that it returns a
+ # boolean or None
+ server_data = cast(
+ Optional[bool], self.manager.gitlab.http_post(path, **kwargs)
+ )
if server_data is True:
self._attrs["state"] = "blocked"
return server_data
@@ -220,7 +224,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
@cli.register_custom_action("User")
@exc.on_http_error(exc.GitlabUnblockError)
- def unblock(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
+ def unblock(self, **kwargs: Any) -> Optional[bool]:
"""Unblock the user.
Args:
@@ -234,7 +238,11 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
Whether the user status has been changed
"""
path = f"/users/{self.encoded_id}/unblock"
- server_data = self.manager.gitlab.http_post(path, **kwargs)
+ # NOTE: Undocumented behavior of the GitLab API is that it returns a
+ # boolean or None
+ server_data = cast(
+ Optional[bool], self.manager.gitlab.http_post(path, **kwargs)
+ )
if server_data is True:
self._attrs["state"] = "active"
return server_data