Skip to content

Commit

Permalink
chore: update imports to prevent shadowing internal exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Nov 25, 2024
1 parent 8c6283a commit 748233c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ft_client/freqtrade_client/ft_rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import requests
from requests.adapters import HTTPAdapter
from requests.exceptions import ConnectionError
from requests.exceptions import ConnectionError as RequestConnectionError


logger = logging.getLogger("ft_rest_client")
Expand Down Expand Up @@ -53,7 +53,7 @@ def _call(self, method, apipath, params: dict | None = None, data=None, files=No
resp = self._session.request(method, url, headers=hd, data=json.dumps(data))
# return resp.text
return resp.json()
except ConnectionError:
except RequestConnectionError:
logger.warning(f"Connection error - could not connect to {netloc}.")

def _get(self, apipath, params: ParamsT = None):
Expand Down
4 changes: 2 additions & 2 deletions ft_client/test_client/test_rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import ANY, MagicMock

import pytest
from requests.exceptions import ConnectionError
from requests.exceptions import ConnectionError as RequestsConnectionError

from freqtrade_client import FtRestClient
from freqtrade_client.ft_client import add_arguments, main_exec
Expand Down Expand Up @@ -45,7 +45,7 @@ def test_FtRestClient_call_invalid(caplog):
with pytest.raises(ValueError):
client._call("PUTTY", "/dummytest")

client._session.request = MagicMock(side_effect=ConnectionError())
client._session.request = MagicMock(side_effect=RequestsConnectionError())
client._call("GET", "/dummytest")

assert log_has_re("Connection error", caplog)
Expand Down

0 comments on commit 748233c

Please sign in to comment.