@@ -59,15 +59,11 @@ class Response:
5959 # Response(raw_resp) would be simpler.
6060 # How is this used in other projects? Jure?
6161 # Maybe we need/want both.
62- def __init__ (
63- self , status : int , data : Any , headers : Optional [dict [Any , Any ]] = None
64- ):
62+ def __init__ (self , status : int , data : Any , headers : Optional [dict [Any , Any ]] = None ):
6563 self .status = status
6664 self .data = data
6765 # [('h1', 'v1'), ('H2', 'V2')] -> {'h1': 'v1', 'h2': 'V2'}
68- self .headers = (
69- dict ((k .lower (), v ) for k , v in dict (headers ).items ()) if headers else {}
70- )
66+ self .headers = dict ((k .lower (), v ) for k , v in dict (headers ).items ()) if headers else {}
7167
7268 self ._json = None
7369
@@ -92,8 +88,7 @@ def __init__(
9288 ):
9389 if not (host or "" ).startswith (("https://" , "http://" )):
9490 raise ScaleComputingError (
95- "Invalid instance host value: '{0}'. "
96- "Value must start with 'https://' or 'http://'" .format (host )
91+ "Invalid instance host value: '{0}'. " "Value must start with 'https://' or 'http://'" .format (host )
9792 )
9893
9994 self .host = host
@@ -213,23 +208,14 @@ def _request_no_log(
213208 except URLError as e :
214209 # TODO: Add other errors here; we need to handle them in modules.
215210 # TimeoutError is handled in the rest_client
216- if (
217- e .args
218- and isinstance (e .args , tuple )
219- and isinstance (e .args [0 ], ConnectionRefusedError )
220- ):
211+ if e .args and isinstance (e .args , tuple ) and isinstance (e .args [0 ], ConnectionRefusedError ):
221212 raise ConnectionRefusedError (e .reason )
222- elif (
223- e .args
224- and isinstance (e .args , tuple )
225- and isinstance (e .args [0 ], ConnectionResetError )
226- ):
213+ elif e .args and isinstance (e .args , tuple ) and isinstance (e .args [0 ], ConnectionResetError ):
227214 raise ConnectionResetError (e .reason )
228215 elif (
229216 e .args
230217 and isinstance (e .args , tuple )
231- and type (e .args [0 ])
232- in [ssl .SSLEOFError , ssl .SSLZeroReturnError , ssl .SSLSyscallError ]
218+ and type (e .args [0 ]) in [ssl .SSLEOFError , ssl .SSLZeroReturnError , ssl .SSLSyscallError ]
233219 ):
234220 raise type (e .args [0 ])(e )
235221 raise ScaleComputingError (e .reason )
@@ -247,9 +233,7 @@ def request(
247233 ) -> Response :
248234 # Make sure we only have one kind of payload
249235 if data is not None and binary_data is not None :
250- raise AssertionError (
251- "Cannot have JSON and binary payload in a single request."
252- )
236+ raise AssertionError ("Cannot have JSON and binary payload in a single request." )
253237 escaped_path = quote (path .strip ("/" ))
254238 if escaped_path :
255239 escaped_path = "/" + escaped_path
@@ -268,9 +252,7 @@ def request(
268252 )
269253 elif binary_data is not None :
270254 headers ["Content-type" ] = "application/octet-stream"
271- return self ._request (
272- method , url , data = binary_data , headers = headers , timeout = timeout
273- )
255+ return self ._request (method , url , data = binary_data , headers = headers , timeout = timeout )
274256 return self ._request (method , url , data = data , headers = headers , timeout = timeout )
275257
276258 def get (
0 commit comments