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

chore: enable mypy checkstrict_equality#2146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 1 commit intomainfromjlvillal/mypy_strict_step_by_step
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletionsgitlab/v4/objects/users.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@
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

Expand DownExpand Up@@ -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:
Expand All@@ -177,7 +177,11 @@ def block(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
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
Expand DownExpand Up@@ -220,7 +224,7 @@ def unfollow(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:

@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:
Expand All@@ -234,7 +238,11 @@ def unblock(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
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
Expand Down
4 changes: 2 additions & 2 deletionspyproject.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,8 @@ disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
no_implicit_reexport = true
strict_equality = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true
Expand All@@ -21,8 +23,6 @@ warn_unused_ignores = true
# disallow_any_generics = true
# disallow_untyped_calls = true
# no_implicit_optional = true
no_implicit_reexport = true
# strict_equality = true
# warn_return_any = true

[[tool.mypy.overrides]] # Overrides for currently untyped modules
Expand Down
16 changes: 14 additions & 2 deletionstests/functional/api/test_users.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,14 +28,26 @@ def test_create_user(gl, fixture_dir):


deftest_block_user(gl,user):
user.block()
result=user.block()
assertresultisTrue
users=gl.users.list(blocked=True)
assertuserinusers

user.unblock()
# block again
result=user.block()
# Trying to block an already blocked user returns None
assertresultisNone

result=user.unblock()
assertresultisTrue
users=gl.users.list(blocked=False)
assertuserinusers

# unblock again
result=user.unblock()
# Trying to unblock an already blocked user returns False
assertresultisFalse


deftest_ban_user(gl,user):
user.ban()
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp