summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2022-07-19 16:41:22 -0700
committerJohn L. Villalovos <john@sodarock.com>2022-07-19 16:41:22 -0700
commita29cd6ce1ff7fa7f31a386cea3e02aa9ba3fb6c2 (patch)
tree876b61cc40580f2dbdfdba0e872a759788f3b139 /gitlab
parented110bd131fd330e20ec55915b9452dbf8002e0b (diff)
downloadgitlab-a29cd6ce1ff7fa7f31a386cea3e02aa9ba3fb6c2.tar.gz
chore: enable mypy check `strict_equality`
Enable the `mypy` `strict_equality` check.
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