Skip to content

fix: Have participants() method use http_list() #2914

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions gitlab/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,9 @@ class ParticipantsMixin(_RestObjectBase):

@cli.register_custom_action(cls_names=("ProjectMergeRequest", "ProjectIssue"))
@exc.on_http_error(exc.GitlabListError)
def participants(self, **kwargs: Any) -> Dict[str, Any]:
def participants(
self, **kwargs: Any
) -> Union[gitlab.client.GitlabList, List[Dict[str, Any]]]:
"""List the participants.

Args:
Expand All @@ -929,7 +931,7 @@ def participants(self, **kwargs: Any) -> Dict[str, Any]:
"""

path = f"{self.manager.path}/{self.encoded_id}/participants"
result = self.manager.gitlab.http_get(path, **kwargs)
result = self.manager.gitlab.http_list(path, **kwargs)
if TYPE_CHECKING:
assert not isinstance(result, requests.Response)
return result
Expand Down
22 changes: 14 additions & 8 deletions gitlab/v4/objects/issues.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Any, cast, Dict, Optional, Tuple, TYPE_CHECKING, Union
from typing import Any, cast, Dict, List, Optional, Tuple, TYPE_CHECKING, Union

from gitlab import cli
import requests

from gitlab import cli, client
from gitlab import exceptions as exc
from gitlab import types
from gitlab.base import RESTManager, RESTObject
Expand Down Expand Up @@ -182,7 +184,9 @@ def reorder(

@cli.register_custom_action(cls_names="ProjectIssue")
@exc.on_http_error(exc.GitlabGetError)
def related_merge_requests(self, **kwargs: Any) -> Dict[str, Any]:
def related_merge_requests(
self, **kwargs: Any
) -> Union[client.GitlabList, List[Dict[str, Any]]]:
"""List merge requests related to the issue.

Args:
Expand All @@ -196,14 +200,16 @@ def related_merge_requests(self, **kwargs: Any) -> Dict[str, Any]:
The list of merge requests.
"""
path = f"{self.manager.path}/{self.encoded_id}/related_merge_requests"
result = self.manager.gitlab.http_get(path, **kwargs)
result = self.manager.gitlab.http_list(path, **kwargs)
if TYPE_CHECKING:
assert isinstance(result, dict)
assert not isinstance(result, requests.Response)
return result

@cli.register_custom_action(cls_names="ProjectIssue")
@exc.on_http_error(exc.GitlabGetError)
def closed_by(self, **kwargs: Any) -> Dict[str, Any]:
def closed_by(
self, **kwargs: Any
) -> Union[client.GitlabList, List[Dict[str, Any]]]:
"""List merge requests that will close the issue when merged.

Args:
Expand All @@ -217,9 +223,9 @@ def closed_by(self, **kwargs: Any) -> Dict[str, Any]:
The list of merge requests.
"""
path = f"{self.manager.path}/{self.encoded_id}/closed_by"
result = self.manager.gitlab.http_get(path, **kwargs)
result = self.manager.gitlab.http_list(path, **kwargs)
if TYPE_CHECKING:
assert isinstance(result, dict)
assert not isinstance(result, requests.Response)
return result


Expand Down
4 changes: 3 additions & 1 deletion tests/functional/api/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def test_create_issue(project):
assert issue in project.issues.list(state="opened")
assert issue2 in project.issues.list(state="closed")

assert issue.participants()
participants = issue.participants()
assert participants
assert isinstance(participants, list)
assert type(issue.closed_by()) == list
assert type(issue.related_merge_requests()) == list

Expand Down
4 changes: 3 additions & 1 deletion tests/functional/api/test_merge_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def test_merge_request_basic(project):
# basic testing: only make sure that the methods exist
mr.commits()
mr.changes()
assert mr.participants()
participants = mr.participants()
assert participants
assert isinstance(participants, list)


def test_merge_request_rebase(project):
Expand Down
Loading