Skip to content

Commit c7d5b71

Browse files
author
Liora Milbaum
committed
refactor: Replacing http_requests return type hint
1 parent a208276 commit c7d5b71

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

gitlab/client.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ def http_request(
653653
retry_transient_errors: Optional[bool] = None,
654654
max_retries: int = 10,
655655
**kwargs: Any,
656-
) -> requests.Response:
656+
) -> _backends.DefaultResponse:
657657
"""Make an HTTP request to the Gitlab server.
658658
659659
Args:
@@ -749,7 +749,7 @@ def http_request(
749749
self._check_redirects(result.response)
750750

751751
if 200 <= result.status_code < 300:
752-
return result.response
752+
return result
753753

754754
def should_retry() -> bool:
755755
if result.status_code == 429 and obey_rate_limit:
@@ -827,9 +827,10 @@ def http_get(
827827
GitlabParsingError: If the json data could not be parsed
828828
"""
829829
query_data = query_data or {}
830-
result = self.http_request(
830+
response = self.http_request(
831831
"get", path, query_data=query_data, streamed=streamed, **kwargs
832832
)
833+
result = response.response
833834

834835
if (
835836
result.headers["Content-Type"] == "application/json"
@@ -1023,7 +1024,7 @@ def http_post(
10231024
query_data = query_data or {}
10241025
post_data = post_data or {}
10251026

1026-
result = self.http_request(
1027+
response = self.http_request(
10271028
"post",
10281029
path,
10291030
query_data=query_data,
@@ -1032,6 +1033,8 @@ def http_post(
10321033
raw=raw,
10331034
**kwargs,
10341035
)
1036+
result = response.response
1037+
10351038
try:
10361039
if result.headers.get("Content-Type", None) == "application/json":
10371040
json_result = result.json()
@@ -1108,7 +1111,8 @@ def http_delete(self, path: str, **kwargs: Any) -> requests.Response:
11081111
Raises:
11091112
GitlabHttpError: When the return code is not 2xx
11101113
"""
1111-
return self.http_request("delete", path, **kwargs)
1114+
response = self.http_request("delete", path, **kwargs)
1115+
return response.response
11121116

11131117
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabSearchError)
11141118
def search(
@@ -1162,7 +1166,9 @@ def _query(
11621166
self, url: str, query_data: Optional[Dict[str, Any]] = None, **kwargs: Any
11631167
) -> None:
11641168
query_data = query_data or {}
1165-
result = self._gl.http_request("get", url, query_data=query_data, **kwargs)
1169+
response = self._gl.http_request("get", url, query_data=query_data, **kwargs)
1170+
result = response.response
1171+
11661172
try:
11671173
next_url = result.links["next"]["url"]
11681174
except KeyError:

0 commit comments

Comments
 (0)