File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -83,10 +83,7 @@ def _http(
8383 ** header_kwargs ,
8484 ** requests_kwargs ,
8585 )
86- if bytes :
87- contents = response .content
88- else :
89- contents = response_contents (response )
86+ contents = response_contents (response = response , bytes = bytes )
9087
9188 try :
9289 response .raise_for_status ()
@@ -103,14 +100,15 @@ def _http(
103100
104101def response_contents (
105102 response : httpx .Response ,
103+ bytes : bool ,
106104) -> JsonObject | str | bytes :
105+ if bytes :
106+ return response .content
107+
107108 if response .headers .get ("content-type" , "" ).startswith ("application/json" ):
108109 return response .json (object_hook = JsonObject )
109- if response .headers .get ("content-type" , "" ).startswith (
110- "application/vnd.github.raw+json"
111- ):
112- return response .text
113- return response .content
110+
111+ return response .text
114112
115113
116114class JsonObject (dict ):
Original file line number Diff line number Diff line change @@ -79,4 +79,4 @@ def test_github_client__get_error_non_json(session, gh):
7979 with pytest .raises (github_client .ApiError ) as exc_info :
8080 gh .repos .get ()
8181
82- assert str (exc_info .value ) == "b' {foobar' "
82+ assert str (exc_info .value ) == "{foobar"
You can’t perform that action at this time.
0 commit comments