8000 fix: issues `closed_by()/related_merge_requests()` use `http_list` · python-gitlab/python-gitlab@de2e4dd · GitHub
[go: up one dir, main page]

Skip to content

Commit de2e4dd

Browse files
JohnVillalovosnejch
authored andcommitted
fix: issues closed_by()/related_merge_requests() use http_list
The `closed_by()` and `related_merge_requests()` API calls return lists. So use the `http_list()` method. This will also warn the user if only a subset of the data is returned.
1 parent d065275 commit de2e4dd

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

gitlab/v4/objects/issues.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from typing import Any, cast, Dict, Optional, Tuple, TYPE_CHECKING, Union
1+
from typing import Any, cast, Dict, List, Optional, Tuple, TYPE_CHECKING, Union
22

3-
from gitlab import cli
3+
import requests
4+
5+
from gitlab import cli, client
46
from gitlab import exceptions as exc
57
from gitlab import types
68
from gitlab.base import RESTManager, RESTObject
@@ -182,7 +184,9 @@ def reorder(
182184

183185
@cli.register_custom_action(cls_names="ProjectIssue")
184186
@exc.on_http_error(exc.GitlabGetError)
185-
def related_merge_requests(self, **kwargs: Any) -> Dict[str, Any]:
187+
def related_merge_requests(
188+
self, **kwargs: Any
189+
) -> Union[client.GitlabList, List[Dict[str, Any]]]:
186190
"""List merge requests related to the issue.
187191
188192
Args:
@@ -196,14 +200,16 @@ def related_merge_requests(self, **kwargs: Any) -> Dict[str, Any]:
196200
The list of merge requests.
197201
"""
198202
path = f"{self.manager.path}/{self.encoded_id}/related_merge_requests"
199-
result = self.manager.gitlab.http_get(path, **kwargs)
203+
result = self.manager.gitlab.http_list(path, **kwargs)
200204
if TYPE_CHECKING:
201-
assert isinstance(result, dict)
205+
assert not isinstance(result, requests.Response)
202206
return result
203207

204208
@cli.register_custom_action(cls_names="ProjectIssue")
205209
@exc.on_http_error(exc.GitlabGetError)
206-
def closed_by(self, **kwargs: Any) -> Dict[str, Any]:
210+
def closed_by(
211+
self, **kwargs: Any
212+
) -> Union[client.GitlabList, List[Dict[str, Any]]]:
207213
"""List merge requests that will close the issue when merged.
208214
209215
Args:
@@ -217,9 +223,9 @@ def closed_by(self, **kwargs: Any) -> Dict[str, Any]:
217223
The list of merge requests.
218224
"""
219225
path = f"{self.manager.path}/{self.encoded_id}/closed_by"
220-
result = self.manager.gitlab.http_get(path, **kwargs)
226+
result = self.manager.gitlab.http_list(path, **kwargs)
221227
if TYPE_CHECKING:
222-
assert isinstance(result, dict)
228+
assert not isinstance(result, requests.Response)
223229
return result
224230

225231

0 commit comments

Comments
 (0)
0