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

Commitf903c7a

Browse files
Liora Milbaumnejch
Liora Milbaum
authored andcommitted
refactor: Replacing http_requests return type hint
1 parent069c6c3 commitf903c7a

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+
)->http_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
if200<=result.status_code<300:
752-
returnresult.response
752+
returnresult
753753

754754
defshould_retry()->bool:
755755
ifresult.status_code==429andobey_rate_limit:
@@ -827,9 +827,10 @@ def http_get(
827827
GitlabParsingError: If the json data could not be parsed
828828
"""
829829
query_data=query_dataor {}
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"
@@ -1010,7 +1011,7 @@ def http_post(
10101011
query_data=query_dataor {}
10111012
post_data=post_dataor {}
10121013

1013-
result=self.http_request(
1014+
response=self.http_request(
10141015
"post",
10151016
path,
10161017
query_data=query_data,
@@ -1019,6 +1020,8 @@ def http_post(
10191020
raw=raw,
10201021
**kwargs,
10211022
)
1023+
result=response.response
1024+
10221025
try:
10231026
ifresult.headers.get("Content-Type",None)=="application/json":
10241027
json_result=result.json()
@@ -1095,7 +1098,8 @@ def http_delete(self, path: str, **kwargs: Any) -> requests.Response:
10951098
Raises:
10961099
GitlabHttpError: When the return code is not 2xx
10971100
"""
1098-
returnself.http_request("delete",path,**kwargs)
1101+
response=self.http_request("delete",path,**kwargs)
1102+
returnresponse.response
10991103

11001104
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabSearchError)
11011105
defsearch(
@@ -1149,7 +1153,9 @@ def _query(
11491153
self,url:str,query_data:Optional[Dict[str,Any]]=None,**kwargs:Any
11501154
)->None:
11511155
query_data=query_dataor {}
1152-
result=self._gl.http_request("get",url,query_data=query_data,**kwargs)
1156+
response=self._gl.http_request("get",url,query_data=query_data,**kwargs)
1157+
result=response.response
1158+
11531159
try:
11541160
next_url=result.links["next"]["url"]
11551161
exceptKeyError:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp