From 8d72ee358c195afc34dbc64cab70b653ddb2f5b0 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 24 Jan 2024 20:31:38 +0100 Subject: [PATCH] Improve code styles ... --- freqtrade/strategy/interface.py | 2 +- tests/commands/test_commands.py | 2 +- tests/data/test_dataprovider.py | 2 +- tests/freqai/test_freqai_datakitchen.py | 2 +- tests/optimize/test_hyperopt.py | 20 ++++++------- tests/optimize/test_lookahead_analysis.py | 18 ++++++------ tests/optimize/test_optimize_reports.py | 2 +- tests/optimize/test_recursive_analysis.py | 8 +++--- tests/plugins/test_remotepairlist.py | 6 ++-- tests/rpc/test_rpc_apiserver.py | 34 +++++++++++------------ tests/rpc/test_rpc_telegram.py | 8 +++--- 11 files changed, 52 insertions(+), 52 deletions(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 675e4a7c1..7f10c2ea2 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -1004,7 +1004,7 @@ class IStrategy(ABC, HyperStrategyMixin): :param is_short: Indicating existing trade direction. :return: (enter, exit) A bool-tuple with enter / exit values. """ - latest, latest_date = self.get_latest_candle(pair, timeframe, dataframe) + latest, _latest_date = self.get_latest_candle(pair, timeframe, dataframe) if latest is None: return False, False, None diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index 567dc213a..caf11be4c 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -1509,7 +1509,7 @@ def test_backtesting_show(mocker, testdatadir, capsys): pargs['config'] = None start_backtesting_show(pargs) assert sbr.call_count == 1 - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert "Pairs for Strategy" in out diff --git a/tests/data/test_dataprovider.py b/tests/data/test_dataprovider.py index e0231d892..cc875b970 100644 --- a/tests/data/test_dataprovider.py +++ b/tests/data/test_dataprovider.py @@ -194,7 +194,7 @@ def test_get_producer_df(default_conf): assert la == empty_la # non existent timeframe, empty dataframe - datframe, la = dataprovider.get_producer_df(pair, timeframe='1h') + _dataframe, la = dataprovider.get_producer_df(pair, timeframe='1h') assert dataframe.empty assert la == empty_la diff --git a/tests/freqai/test_freqai_datakitchen.py b/tests/freqai/test_freqai_datakitchen.py index 901abd21b..ba1520601 100644 --- a/tests/freqai/test_freqai_datakitchen.py +++ b/tests/freqai/test_freqai_datakitchen.py @@ -76,7 +76,7 @@ def test_filter_features(mocker, freqai_conf): freqai, unfiltered_dataframe = make_unfiltered_dataframe(mocker, freqai_conf) freqai.dk.find_features(unfiltered_dataframe) - filtered_df, labels = freqai.dk.filter_features( + filtered_df, _labels = freqai.dk.filter_features( unfiltered_dataframe, freqai.dk.training_features_list, freqai.dk.label_list, diff --git a/tests/optimize/test_hyperopt.py b/tests/optimize/test_hyperopt.py index 67f776c7e..be27bb3f5 100644 --- a/tests/optimize/test_hyperopt.py +++ b/tests/optimize/test_hyperopt.py @@ -254,7 +254,7 @@ def test_log_results_if_loss_improves(hyperopt, capsys) -> None: 'is_best': True } ) - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert all(x in out for x in ["Best", "2/2", " 1", "0.10%", "0.00100000 BTC (1.00%)", "00:20:00"]) @@ -333,7 +333,7 @@ def test_start_calls_optimizer(mocker, hyperopt_conf, capsys) -> None: parallel.assert_called_once() - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert 'Best result:\n\n* 1/1: foo result Objective: 1.00000\n' in out # Should be called for historical candle data assert dumper.call_count == 1 @@ -577,7 +577,7 @@ def test_print_json_spaces_all(mocker, hyperopt_conf, capsys) -> None: parallel.assert_called_once() - out, err = capsys.readouterr() + out, _err = capsys.readouterr() result_str = ( '{"params":{"mfi-value":null,"sell-mfi-value":null},"minimal_roi"' ':{},"stoploss":null,"trailing_stop":null,"max_open_trades":null}' @@ -624,7 +624,7 @@ def test_print_json_spaces_default(mocker, hyperopt_conf, capsys) -> None: parallel.assert_called_once() - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert '{"params":{"mfi-value":null,"sell-mfi-value":null},"minimal_roi":{},"stoploss":null}' in out # noqa: E501 # Should be called for historical candle data assert dumper.call_count == 1 @@ -666,7 +666,7 @@ def test_print_json_spaces_roi_stoploss(mocker, hyperopt_conf, capsys) -> None: parallel.assert_called_once() - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert '{"minimal_roi":{},"stoploss":null}' in out assert dumper.call_count == 1 @@ -704,7 +704,7 @@ def test_simplified_interface_roi_stoploss(mocker, hyperopt_conf, capsys) -> Non parallel.assert_called_once() - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert 'Best result:\n\n* 1/1: foo result Objective: 1.00000\n' in out assert dumper.call_count == 1 assert dumper2.call_count == 1 @@ -777,7 +777,7 @@ def test_simplified_interface_buy(mocker, hyperopt_conf, capsys) -> None: parallel.assert_called_once() - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert 'Best result:\n\n* 1/1: foo result Objective: 1.00000\n' in out assert dumper.called assert dumper.call_count == 1 @@ -819,7 +819,7 @@ def test_simplified_interface_sell(mocker, hyperopt_conf, capsys) -> None: parallel.assert_called_once() - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert 'Best result:\n\n* 1/1: foo result Objective: 1.00000\n' in out assert dumper.called assert dumper.call_count == 1 @@ -1051,7 +1051,7 @@ def test_max_open_trades_dump(mocker, hyperopt_conf, tmp_path, fee, capsys) -> N hyperopt.start() - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert 'max_open_trades = -1' in out assert 'max_open_trades = inf' not in out @@ -1070,7 +1070,7 @@ def test_max_open_trades_dump(mocker, hyperopt_conf, tmp_path, fee, capsys) -> N hyperopt.start() - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert '"max_open_trades":-1' in out diff --git a/tests/optimize/test_lookahead_analysis.py b/tests/optimize/test_lookahead_analysis.py index 8b13bddea..d7c4bc6fa 100644 --- a/tests/optimize/test_lookahead_analysis.py +++ b/tests/optimize/test_lookahead_analysis.py @@ -143,8 +143,8 @@ def test_lookahead_helper_text_table_lookahead_analysis_instances(lookahead_conf instance = LookaheadAnalysis(lookahead_conf, strategy_obj) instance.current_analysis = analysis - table, headers, data = (LookaheadAnalysisSubFunctions. - text_table_lookahead_analysis_instances(lookahead_conf, [instance])) + _table, _headers, data = (LookaheadAnalysisSubFunctions. + text_table_lookahead_analysis_instances(lookahead_conf, [instance])) # check row contents for a try that has too few signals assert data[0][0] == 'strategy_test_v3_with_lookahead_bias.py' @@ -158,14 +158,14 @@ def test_lookahead_helper_text_table_lookahead_analysis_instances(lookahead_conf analysis.false_exit_signals = 10 instance = LookaheadAnalysis(lookahead_conf, strategy_obj) instance.current_analysis = analysis - table, headers, data = (LookaheadAnalysisSubFunctions. - text_table_lookahead_analysis_instances(lookahead_conf, [instance])) + _table, _headers, data = (LookaheadAnalysisSubFunctions. + text_table_lookahead_analysis_instances(lookahead_conf, [instance])) assert data[0][2].__contains__("error") # edit it into not showing an error instance.failed_bias_check = False - table, headers, data = (LookaheadAnalysisSubFunctions. - text_table_lookahead_analysis_instances(lookahead_conf, [instance])) + _table, _headers, data = (LookaheadAnalysisSubFunctions. + text_table_lookahead_analysis_instances(lookahead_conf, [instance])) assert data[0][0] == 'strategy_test_v3_with_lookahead_bias.py' assert data[0][1] == 'strategy_test_v3_with_lookahead_bias' assert data[0][2] # True @@ -176,8 +176,8 @@ def test_lookahead_helper_text_table_lookahead_analysis_instances(lookahead_conf analysis.false_indicators.append('falseIndicator1') analysis.false_indicators.append('falseIndicator2') - table, headers, data = (LookaheadAnalysisSubFunctions. - text_table_lookahead_analysis_instances(lookahead_conf, [instance])) + _table, _headers, data = (LookaheadAnalysisSubFunctions. + text_table_lookahead_analysis_instances(lookahead_conf, [instance])) assert data[0][6] == 'falseIndicator1, falseIndicator2' @@ -185,7 +185,7 @@ def test_lookahead_helper_text_table_lookahead_analysis_instances(lookahead_conf assert len(data) == 1 # check amount of multiple rows - table, headers, data = (LookaheadAnalysisSubFunctions.text_table_lookahead_analysis_instances( + _table, _headers, data = (LookaheadAnalysisSubFunctions.text_table_lookahead_analysis_instances( lookahead_conf, [instance, instance, instance])) assert len(data) == 3 diff --git a/tests/optimize/test_optimize_reports.py b/tests/optimize/test_optimize_reports.py index a65c3f277..0f190f3f5 100644 --- a/tests/optimize/test_optimize_reports.py +++ b/tests/optimize/test_optimize_reports.py @@ -513,7 +513,7 @@ def test_show_sorted_pairlist(testdatadir, default_conf, capsys): show_sorted_pairlist(default_conf, bt_data) - out, err = capsys.readouterr() + out, _err = capsys.readouterr() assert 'Pairs for Strategy StrategyTestV3: \n[' in out assert 'TOTAL' not in out assert '"ETH/BTC", // ' in out diff --git a/tests/optimize/test_recursive_analysis.py b/tests/optimize/test_recursive_analysis.py index aad465ff3..33fae0d08 100644 --- a/tests/optimize/test_recursive_analysis.py +++ b/tests/optimize/test_recursive_analysis.py @@ -107,8 +107,8 @@ def test_recursive_helper_text_table_recursive_analysis_instances(recursive_conf instance = RecursiveAnalysis(recursive_conf, strategy_obj) instance.dict_recursive = dict_diff - table, headers, data = (RecursiveAnalysisSubFunctions. - text_table_recursive_analysis_instances([instance])) + _table, _headers, data = (RecursiveAnalysisSubFunctions. + text_table_recursive_analysis_instances([instance])) # check row contents for a try that has too few signals assert data[0][0] == 'rsi' @@ -119,8 +119,8 @@ def test_recursive_helper_text_table_recursive_analysis_instances(recursive_conf dict_diff = dict() instance = RecursiveAnalysis(recursive_conf, strategy_obj) instance.dict_recursive = dict_diff - table, headers, data = (RecursiveAnalysisSubFunctions. - text_table_recursive_analysis_instances([instance])) + _table, _headers, data = (RecursiveAnalysisSubFunctions. + text_table_recursive_analysis_instances([instance])) assert len(data) == 0 diff --git a/tests/plugins/test_remotepairlist.py b/tests/plugins/test_remotepairlist.py index 9814e5662..b21763d47 100644 --- a/tests/plugins/test_remotepairlist.py +++ b/tests/plugins/test_remotepairlist.py @@ -108,7 +108,7 @@ def test_fetch_pairlist_timeout_keep_last_pairlist(mocker, rpl_config, caplog): remote_pairlist._last_pairlist = ["BTC/USDT", "ETH/USDT", "LTC/USDT"] - pairs, time_elapsed = remote_pairlist.fetch_pairlist() + pairs, _time_elapsed = remote_pairlist.fetch_pairlist() assert log_has(f"Was not able to fetch pairlist from: {remote_pairlist._pairlist_url}", caplog) assert log_has("Keeping last fetched pairlist", caplog) assert pairs == ["BTC/USDT", "ETH/USDT", "LTC/USDT"] @@ -281,7 +281,7 @@ def test_remote_pairlist_blacklist(mocker, rpl_config, caplog, markets, tickers) remote_pairlist = RemotePairList(exchange, pairlistmanager, rpl_config, rpl_config["pairlists"][1], 1) - pairs, time_elapsed = remote_pairlist.fetch_pairlist() + pairs, _time_elapsed = remote_pairlist.fetch_pairlist() assert pairs == ["XRP/USDT"] @@ -334,7 +334,7 @@ def test_remote_pairlist_whitelist(mocker, rpl_config, processing_mode, markets, remote_pairlist = RemotePairList(exchange, pairlistmanager, rpl_config, rpl_config["pairlists"][1], 1) - pairs, time_elapsed = remote_pairlist.fetch_pairlist() + pairs, _time_elapsed = remote_pairlist.fetch_pairlist() assert pairs == ["XRP/USDT"] diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index 81d01acad..9df26ad4e 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -112,7 +112,7 @@ def assert_response(response, expected_code=200, needs_cors=True): def test_api_not_found(botclient): - ftbot, client = botclient + _ftbot, client = botclient rc = client_get(client, f"{BASE_URI}/invalid_url") assert_response(rc, 404) @@ -120,7 +120,7 @@ def test_api_not_found(botclient): def test_api_ui_fallback(botclient, mocker): - ftbot, client = botclient + _ftbot, client = botclient rc = client_get(client, "/favicon.ico") assert rc.status_code == 200 @@ -150,7 +150,7 @@ def test_api_ui_fallback(botclient, mocker): def test_api_ui_version(botclient, mocker): - ftbot, client = botclient + _ftbot, client = botclient mocker.patch('freqtrade.commands.deploy_commands.read_ui_version', return_value='0.1.2') rc = client_get(client, "/ui_version") @@ -230,7 +230,7 @@ def test_api_unauthorized(botclient): def test_api_token_login(botclient): - ftbot, client = botclient + _ftbot, client = botclient rc = client.post(f"{BASE_URI}/token/login", data=None, headers={'Authorization': _basic_auth_str('WRONG_USER', 'WRONG_PASS'), @@ -249,7 +249,7 @@ def test_api_token_login(botclient): def test_api_token_refresh(botclient): - ftbot, client = botclient + _ftbot, client = botclient rc = client_post(client, f"{BASE_URI}/token/login") assert_response(rc) rc = client.post(f"{BASE_URI}/token/refresh", @@ -541,7 +541,7 @@ def test_api_count(botclient, mocker, ticker, fee, markets, is_short): def test_api_locks(botclient): - ftbot, client = botclient + _ftbot, client = botclient rc = client_get(client, f"{BASE_URI}/locks") assert_response(rc) @@ -821,7 +821,7 @@ def test_api_trade_reload_trade(botclient, mocker, fee, markets, ticker, is_shor def test_api_logs(botclient): - ftbot, client = botclient + _ftbot, client = botclient rc = client_get(client, f"{BASE_URI}/logs") assert_response(rc) assert len(rc.json()) == 2 @@ -1228,7 +1228,7 @@ def test_api_status(botclient, mocker, ticker, fee, markets, is_short, def test_api_version(botclient): - ftbot, client = botclient + _ftbot, client = botclient rc = client_get(client, f"{BASE_URI}/version") assert_response(rc) @@ -1236,7 +1236,7 @@ def test_api_version(botclient): def test_api_blacklist(botclient, mocker): - ftbot, client = botclient + _ftbot, client = botclient rc = client_get(client, f"{BASE_URI}/blacklist") assert_response(rc) @@ -1303,7 +1303,7 @@ def test_api_blacklist(botclient, mocker): def test_api_whitelist(botclient): - ftbot, client = botclient + _ftbot, client = botclient rc = client_get(client, f"{BASE_URI}/whitelist") assert_response(rc) @@ -1558,7 +1558,7 @@ def test_api_pair_candles(botclient, ohlcv_history): def test_api_pair_history(botclient, mocker): - ftbot, client = botclient + _ftbot, client = botclient timeframe = '5m' lfm = mocker.patch('freqtrade.strategy.interface.IStrategy.load_freqAI_model') # No pair @@ -1698,7 +1698,7 @@ def test_api_strategies(botclient, tmp_path): def test_api_strategy(botclient): - ftbot, client = botclient + _ftbot, client = botclient rc = client_get(client, f"{BASE_URI}/strategy/{CURRENT_TEST_STRATEGY}") @@ -1717,7 +1717,7 @@ def test_api_strategy(botclient): def test_api_exchanges(botclient): - ftbot, client = botclient + _ftbot, client = botclient rc = client_get(client, f"{BASE_URI}/exchanges") assert_response(rc) @@ -1954,7 +1954,7 @@ def test_list_available_pairs(botclient): def test_sysinfo(botclient): - ftbot, client = botclient + _ftbot, client = botclient rc = client_get(client, f"{BASE_URI}/sysinfo") assert_response(rc) @@ -2234,7 +2234,7 @@ def test_api_patch_backtest_history_entry(botclient, tmp_path: Path): def test_health(botclient): - ftbot, client = botclient + _ftbot, client = botclient rc = client_get(client, f"{BASE_URI}/health") @@ -2245,7 +2245,7 @@ def test_health(botclient): def test_api_ws_subscribe(botclient, mocker): - ftbot, client = botclient + _ftbot, client = botclient ws_url = f"/api/v1/message/ws?token={_TEST_WS_TOKEN}" sub_mock = mocker.patch('freqtrade.rpc.api_server.ws.WebSocketChannel.set_subscriptions') @@ -2268,7 +2268,7 @@ def test_api_ws_subscribe(botclient, mocker): def test_api_ws_requests(botclient, caplog): caplog.set_level(logging.DEBUG) - ftbot, client = botclient + _ftbot, client = botclient ws_url = f"/api/v1/message/ws?token={_TEST_WS_TOKEN}" # Test whitelist request diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index e5ec3073e..f85b19a01 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -599,7 +599,7 @@ async def test_daily_handle(default_conf_usdt, update, ticker, fee, mocker, time get_fee=fee, ) - telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf_usdt) + telegram, _freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf_usdt) # Move date to within day time_machine.move_to('2022-06-11 08:00:00+00:00') @@ -1480,7 +1480,7 @@ async def test_telegram_performance_handle(default_conf_usdt, update, ticker, fe fetch_ticker=ticker, get_fee=fee, ) - telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf_usdt) + telegram, _freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf_usdt) # Create some test data create_mock_trades_usdt(fee) @@ -1655,7 +1655,7 @@ async def test_telegram_lock_handle(default_conf, update, ticker, fee, mocker) - async def test_whitelist_static(default_conf, update, mocker) -> None: - telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf) + telegram, _freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf) await telegram._whitelist(update=update, context=MagicMock()) assert msg_mock.call_count == 1 @@ -2647,7 +2647,7 @@ async def test__send_msg_keyboard(default_conf, mocker, caplog) -> None: async def test_change_market_direction(default_conf, mocker, update) -> None: - telegram, _, msg_mock = get_telegram_testobject(mocker, default_conf) + telegram, _, _msg_mock = get_telegram_testobject(mocker, default_conf) assert telegram._rpc._freqtrade.strategy.market_direction == MarketDirection.NONE context = MagicMock() context.args = ["long"]