diff --git a/freqtrade/commands/analyze_commands.py b/freqtrade/commands/analyze_commands.py index 20afa7ffd..e928ccad7 100644 --- a/freqtrade/commands/analyze_commands.py +++ b/freqtrade/commands/analyze_commands.py @@ -40,8 +40,8 @@ def setup_analyze_configuration(args: Dict[str, Any], method: RunMode) -> Dict[s if (not Path(signals_file).exists()): raise OperationalException( - (f"Cannot find latest backtest signals file: {signals_file}." - "Run backtesting with `--export signals`.") + f"Cannot find latest backtest signals file: {signals_file}." + "Run backtesting with `--export signals`." ) return config diff --git a/freqtrade/optimize/hyperopt_tools.py b/freqtrade/optimize/hyperopt_tools.py index cf0650f7d..93efbf644 100644 --- a/freqtrade/optimize/hyperopt_tools.py +++ b/freqtrade/optimize/hyperopt_tools.py @@ -1,4 +1,3 @@ -import io import logging from copy import deepcopy from datetime import datetime, timezone @@ -464,7 +463,7 @@ class HyperoptTools(): return try: - io.open(csv_file, 'w+').close() + Path(csv_file).open('w+').close() except IOError: logger.error(f"Failed to create CSV file: {csv_file}") return diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 0c0b24f00..cb219eef1 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -1340,7 +1340,7 @@ class Telegram(RPCHandler): message = tabulate({k: [v] for k, v in counts.items()}, headers=['current', 'max', 'total stake'], tablefmt='simple') - message = "
{}".format(message)
+ message = f"{message}"
logger.debug(message)
self._send_msg(message, parse_mode=ParseMode.HTML,
reload_able=True, callback_path="update_count",
@@ -1642,7 +1642,7 @@ class Telegram(RPCHandler):
])
else:
reply_markup = InlineKeyboardMarkup([[]])
- msg += "\nUpdated: {}".format(datetime.now().ctime())
+ msg += f"\nUpdated: {datetime.now().ctime()}"
if not query.message:
return
chat_id = query.message.chat_id
diff --git a/freqtrade/rpc/webhook.py b/freqtrade/rpc/webhook.py
index 0967de70d..118ebed88 100644
--- a/freqtrade/rpc/webhook.py
+++ b/freqtrade/rpc/webhook.py
@@ -113,7 +113,7 @@ class Webhook(RPCHandler):
response = post(self._url, data=payload['data'],
headers={'Content-Type': 'text/plain'})
else:
- raise NotImplementedError('Unknown format: {}'.format(self._format))
+ raise NotImplementedError(f'Unknown format: {self._format}')
# Throw a RequestException if the post was not successful
response.raise_for_status()
diff --git a/tests/data/test_btanalysis.py b/tests/data/test_btanalysis.py
index 345e3c299..2c5515f7c 100644
--- a/tests/data/test_btanalysis.py
+++ b/tests/data/test_btanalysis.py
@@ -98,7 +98,7 @@ def test_load_backtest_data_new_format(testdatadir):
assert bt_data.equals(bt_data3)
with pytest.raises(ValueError, match=r"File .* does not exist\."):
- load_backtest_data(str("filename") + "nofile")
+ load_backtest_data("filename" + "nofile")
with pytest.raises(ValueError, match=r"Unknown dataformat."):
load_backtest_data(testdatadir / "backtest_results" / LAST_BT_RESULT_FN)
diff --git a/tests/data/test_history.py b/tests/data/test_history.py
index c967f0c89..24ad8bcc9 100644
--- a/tests/data/test_history.py
+++ b/tests/data/test_history.py
@@ -409,7 +409,7 @@ def test_init_with_refresh(default_conf, mocker) -> None:
def test_file_dump_json_tofile(testdatadir) -> None:
- file = testdatadir / 'test_{id}.json'.format(id=str(uuid.uuid4()))
+ file = testdatadir / f'test_{uuid.uuid4()}.json'
data = {'bar': 'foo'}
# check the file we will create does not exist
diff --git a/tests/optimize/test_optimize_reports.py b/tests/optimize/test_optimize_reports.py
index f71e6c492..0cc32baaf 100644
--- a/tests/optimize/test_optimize_reports.py
+++ b/tests/optimize/test_optimize_reports.py
@@ -236,7 +236,7 @@ def test_store_backtest_candles(testdatadir, mocker):
assert dump_mock.call_count == 1
assert isinstance(dump_mock.call_args_list[0][0][0], Path)
- assert str(dump_mock.call_args_list[0][0][0]).endswith(str('_signals.pkl'))
+ assert str(dump_mock.call_args_list[0][0][0]).endswith('_signals.pkl')
dump_mock.reset_mock()
# mock file exporting
@@ -245,7 +245,7 @@ def test_store_backtest_candles(testdatadir, mocker):
assert dump_mock.call_count == 1
assert isinstance(dump_mock.call_args_list[0][0][0], Path)
# result will be testdatadir / testresult-