fix: more pylint fixes

This commit is contained in:
Seaswimmer 2023-12-20 23:50:30 -05:00
parent ecdca8f0ee
commit 22d1205a26
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -35,7 +35,7 @@ class RestAdapter:
if not ssl and not enforced_signing:
disable_warnings()
def _do(self, http_method: str, endpoint: str, params: Dict = None, data: Dict = None) -> Result:
def _do(self, http_method: str, endpoint: str, params: Dict = None, data: Dict = None, timeout: float = 60) -> Result:
"""Internal method to make a request to the Zipline server. You shouldn't use this directly.
Args:
@ -43,6 +43,7 @@ class RestAdapter:
endpoint (str): The endpoint to make the request to.
params (Dict = None): Python dictionary of query parameters to send with the request.
data (Dict = None): Python dictionary of data to send with the request.
timeout (float = 60): Number of seconds to wait for the request to complete.
Returns:
Result: A Result object containing the status code, message, and data from the request.
@ -56,9 +57,9 @@ class RestAdapter:
try: # Perform an HTTP request, catching and re-raising any exceptions
# will eventually refactor this to use asyncio/aiohttp instead for async operation
response = requests.request(method=http_method, url=full_url, verify=self._enforced_signing, params=params, headers=headers, json=data)
response = requests.request(method=http_method, url=full_url, verify=self._enforced_signing, params=params, headers=headers, json=data, timeout=timeout)
except requests.exceptions.RequestException as e:
self._logger.error(msg=(str(e)))
self._logger.error(msg=str(e))
raise HTTPFailure("Could not connect to Zipline server") from e
try: # Deserialize JSON output to Python object, or return failed Result on exception
@ -71,8 +72,8 @@ class RestAdapter:
if is_success:
return Result(success=is_success, status_code=response.status_code, message=response.reason, data=data_out)
else:
return Result(success=is_success, status_code=response.status_code, message=data_out['error'], data=data_out)
return Result(success=is_success, status_code=response.status_code, message=data_out['error'], data=data_out)
def get(self, endpoint: str, params: Dict = None) -> Result:
"""Make a GET request to the Zipline server. You should almost never have to use this directly.