Skip to content

Commit 70d9ac0

Browse files
authored
Merge pull request freqtrade#11230 from freqtrade/dependabot/pip/develop/ruff-0.9.1
chore(deps-dev): bump ruff from 0.8.6 to 0.9.1
2 parents 5b555cc + be2907a commit 70d9ac0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+71
-90
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repos:
3131

3232
- repo: https://github.com/charliermarsh/ruff-pre-commit
3333
# Ruff version.
34-
rev: 'v0.8.6'
34+
rev: 'v0.9.1'
3535
hooks:
3636
- id: ruff
3737
- id: ruff-format

freqtrade/commands/cli_options.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def __init__(self, *args, **kwargs):
334334
help="Specify the class name of the hyperopt loss function class (IHyperOptLoss). "
335335
"Different functions can generate completely different results, "
336336
"since the target for optimization is different. Built-in Hyperopt-loss-functions are: "
337-
f'{", ".join(HYPEROPT_LOSS_BUILTIN)}',
337+
f"{', '.join(HYPEROPT_LOSS_BUILTIN)}",
338338
metavar="NAME",
339339
),
340340
"hyperoptexportfilename": Arg(
@@ -663,8 +663,7 @@ def __init__(self, *args, **kwargs):
663663
"--ignore-missing-spaces",
664664
"--ignore-unparameterized-spaces",
665665
help=(
666-
"Suppress errors for any requested Hyperopt spaces "
667-
"that do not contain any parameters."
666+
"Suppress errors for any requested Hyperopt spaces that do not contain any parameters."
668667
),
669668
action="store_true",
670669
),

freqtrade/commands/data_commands.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
def _check_data_config_download_sanity(config: Config) -> None:
1616
if "days" in config and "timerange" in config:
1717
raise ConfigurationError(
18-
"--days and --timerange are mutually exclusive. "
19-
"You can only specify one or the other."
18+
"--days and --timerange are mutually exclusive. You can only specify one or the other."
2019
)
2120

2221
if "pairs" not in config:

freqtrade/data/history/history_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ def _download_pair_history(
259259
logger.info(
260260
f'Download history data for "{pair}", {timeframe}, '
261261
f"{candle_type} and store in {datadir}. "
262-
f'From {format_ms_time(since_ms) if since_ms else "start"} to '
263-
f'{format_ms_time(until_ms) if until_ms else "now"}'
262+
f"From {format_ms_time(since_ms) if since_ms else 'start'} to "
263+
f"{format_ms_time(until_ms) if until_ms else 'now'}"
264264
)
265265

266266
logger.debug(

freqtrade/exchange/check_exchange.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,29 @@ def check_exchange(config: Config, check_for_bad: bool = True) -> bool:
3636
f"This command requires a configured exchange. You should either use "
3737
f"`--exchange <exchange_name>` or specify a configuration file via `--config`.\n"
3838
f"The following exchanges are available for Freqtrade: "
39-
f'{", ".join(available_exchanges())}'
39+
f"{', '.join(available_exchanges())}"
4040
)
4141

4242
if not is_exchange_known_ccxt(exchange):
4343
raise OperationalException(
4444
f'Exchange "{exchange}" is not known to the ccxt library '
4545
f"and therefore not available for the bot.\n"
4646
f"The following exchanges are available for Freqtrade: "
47-
f'{", ".join(available_exchanges())}'
47+
f"{', '.join(available_exchanges())}"
4848
)
4949

5050
valid, reason, _ = validate_exchange(exchange)
5151
if not valid:
5252
if check_for_bad:
5353
raise OperationalException(
54-
f'Exchange "{exchange}" will not work with Freqtrade. ' f"Reason: {reason}"
54+
f'Exchange "{exchange}" will not work with Freqtrade. Reason: {reason}'
5555
)
5656
else:
5757
logger.warning(f'Exchange "{exchange}" will not work with Freqtrade. Reason: {reason}')
5858

5959
if MAP_EXCHANGE_CHILDCLASS.get(exchange, exchange) in SUPPORTED_EXCHANGES:
6060
logger.info(
61-
f'Exchange "{exchange}" is officially supported ' f"by the Freqtrade development team."
61+
f'Exchange "{exchange}" is officially supported by the Freqtrade development team.'
6262
)
6363
else:
6464
logger.warning(

freqtrade/exchange/exchange.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3004,8 +3004,7 @@ async def _async_get_trade_history_id(
30043004
trades.extend(t[x])
30053005
if from_id == from_id_next or t[-1][0] > until:
30063006
logger.debug(
3007-
f"Stopping because from_id did not change. "
3008-
f"Reached {t[-1][0]} > {until}"
3007+
f"Stopping because from_id did not change. Reached {t[-1][0]} > {until}"
30093008
)
30103009
# Reached the end of the defined-download period - add last trade as well.
30113010
if has_overlap:

freqtrade/freqai/RL/BaseReinforcementLearningModel.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ def train(self, unfiltered_df: DataFrame, pair: str, dk: FreqaiDataKitchen, **kw
138138
)
139139

140140
logger.info(
141-
f'Training model on {len(dk.data_dictionary["train_features"].columns)}'
142-
f' features and {len(dd["train_features"])} data points'
141+
f"Training model on {len(dk.data_dictionary['train_features'].columns)}"
142+
f" features and {len(dd['train_features'])} data points"
143143
)
144144

145145
self.set_train_and_eval_environments(dd, prices_train, prices_test, dk)
@@ -346,8 +346,7 @@ def build_ohlc_price_dataframes(
346346
)
347347
elif prices_train.empty:
348348
raise OperationalException(
349-
"No prices found, please follow log warning "
350-
"instructions to correct the strategy."
349+
"No prices found, please follow log warning instructions to correct the strategy."
351350
)
352351

353352
prices_train.rename(columns=rename_dict, inplace=True)

freqtrade/freqai/base_models/FreqaiMultiOutputClassifier.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def fit(self, X, y, sample_weight=None, fit_params=None):
4343

4444
if y.ndim == 1:
4545
raise ValueError(
46-
"y must have at least two dimensions for "
47-
"multi-output regression but has only one."
46+
"y must have at least two dimensions for multi-output regression but has only one."
4847
)
4948

5049
if sample_weight is not None and not has_fit_parameter(self.estimator, "sample_weight"):

freqtrade/freqai/base_models/FreqaiMultiOutputRegressor.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ def fit(self, X, y, sample_weight=None, fit_params=None):
3535

3636
if y.ndim == 1:
3737
raise ValueError(
38-
"y must have at least two dimensions for "
39-
"multi-output regression but has only one."
38+
"y must have at least two dimensions for multi-output regression but has only one."
4039
)
4140

4241
if sample_weight is not None and not has_fit_parameter(self.estimator, "sample_weight"):

freqtrade/freqai/freqai_interface.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def start_live(
426426
# append the historic data once per round
427427
if self.dd.historic_data:
428428
self.dd.update_historic_data(strategy, dk)
429-
logger.debug(f'Updating historic data on pair {metadata["pair"]}')
429+
logger.debug(f"Updating historic data on pair {metadata['pair']}")
430430
self.track_current_candle()
431431

432432
(_, new_trained_timerange, data_load_timerange) = dk.check_if_new_training_required(

freqtrade/freqai/prediction_models/SKLearnRandomForestClassifier.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def fit(self, data_dictionary: dict, dk: FreqaiDataKitchen, **kwargs) -> Any:
4545

4646
if self.freqai_info.get("continual_learning", False):
4747
logger.warning(
48-
"Continual learning is not supported for "
49-
"SKLearnRandomForestClassifier, ignoring."
48+
"Continual learning is not supported for SKLearnRandomForestClassifier, ignoring."
5049
)
5150

5251
train_weights = data_dictionary["train_weights"]

freqtrade/optimize/analysis/lookahead.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ def start(self) -> None:
208208
found_signals: int = self.full_varHolder.result["results"].shape[0] + 1
209209
if found_signals >= self.targeted_trade_amount:
210210
logger.info(
211-
f"Found {found_signals} trades, "
212-
f"calculating {self.targeted_trade_amount} trades."
211+
f"Found {found_signals} trades, calculating {self.targeted_trade_amount} trades."
213212
)
214213
elif self.targeted_trade_amount >= found_signals >= self.minimum_trade_amount:
215214
logger.info(f"Only found {found_signals} trades. Calculating all available trades.")

freqtrade/optimize/analysis/recursive_helpers.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,5 @@ def start(config: Config):
112112
)
113113
else:
114114
logger.error(
115-
"There was no strategy specified through --strategy "
116-
"or timeframe was not specified."
115+
"There was no strategy specified through --strategy or timeframe was not specified."
117116
)

freqtrade/optimize/optimize_reports/bt_output.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,15 @@ def text_table_strategy(strategy_results, stake_currency: str, title: str):
163163

164164
# Align drawdown string on the center two space separator.
165165
if "max_drawdown_account" in strategy_results[0]:
166-
drawdown = [f'{t["max_drawdown_account"] * 100:.2f}' for t in strategy_results]
166+
drawdown = [f"{t['max_drawdown_account'] * 100:.2f}" for t in strategy_results]
167167
else:
168168
# Support for prior backtest results
169-
drawdown = [f'{t["max_drawdown_per"]:.2f}' for t in strategy_results]
169+
drawdown = [f"{t['max_drawdown_per']:.2f}" for t in strategy_results]
170170

171171
dd_pad_abs = max([len(t["max_drawdown_abs"]) for t in strategy_results])
172172
dd_pad_per = max([len(dd) for dd in drawdown])
173173
drawdown = [
174-
f'{t["max_drawdown_abs"]:>{dd_pad_abs}} {stake_currency} {dd:>{dd_pad_per}}%'
174+
f"{t['max_drawdown_abs']:>{dd_pad_abs}} {stake_currency} {dd:>{dd_pad_per}}%"
175175
for t, dd in zip(strategy_results, drawdown, strict=False)
176176
]
177177

@@ -315,7 +315,7 @@ def text_table_add_metrics(strat_results: dict) -> None:
315315
(
316316
"Profit factor",
317317
(
318-
f'{strat_results["profit_factor"]:.2f}'
318+
f"{strat_results['profit_factor']:.2f}"
319319
if "profit_factor" in strat_results
320320
else "N/A"
321321
),

freqtrade/persistence/models.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def init_db(db_url: str) -> None:
7575
engine = create_engine(db_url, future=True, **kwargs)
7676
except NoSuchModuleError:
7777
raise OperationalException(
78-
f"Given value for db_url: '{db_url}' "
79-
f"is no valid database URL! (See {_SQL_DOCS_URL})"
78+
f"Given value for db_url: '{db_url}' is no valid database URL! (See {_SQL_DOCS_URL})"
8079
)
8180

8281
# https://docs.sqlalchemy.org/en/13/orm/contextual.html#thread-local-scope

freqtrade/plot/plotting.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def add_indicators(fig, row, indicators: dict[str, dict], data: pd.DataFrame) ->
145145
fig.add_trace(trace, row, 1)
146146
else:
147147
logger.info(
148-
'Indicator "%s" ignored. Reason: This indicator is not found ' "in your strategy.",
148+
'Indicator "%s" ignored. Reason: This indicator is not found in your strategy.',
149149
indicator,
150150
)
151151

@@ -394,13 +394,12 @@ def add_areas(fig, row: int, data: pd.DataFrame, indicators) -> make_subplots:
394394
)
395395
elif indicator not in data:
396396
logger.info(
397-
'Indicator "%s" ignored. Reason: This indicator is not '
398-
"found in your strategy.",
397+
'Indicator "%s" ignored. Reason: This indicator is not found in your strategy.',
399398
indicator,
400399
)
401400
elif indicator_b not in data:
402401
logger.info(
403-
'fill_to: "%s" ignored. Reason: This indicator is not ' "in your strategy.",
402+
'fill_to: "%s" ignored. Reason: This indicator is not in your strategy.',
404403
indicator_b,
405404
)
406405
return fig

freqtrade/plugins/pairlist/PriceFilter.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ def _validate_pair(self, pair: str, ticker: Ticker | None) -> bool:
158158
if self._min_price != 0:
159159
if price < self._min_price:
160160
self.log_once(
161-
f"Removed {pair} from whitelist, "
162-
f"because last price < {self._min_price:.8f}",
161+
f"Removed {pair} from whitelist, because last price < {self._min_price:.8f}",
163162
logger.info,
164163
)
165164
return False
@@ -168,8 +167,7 @@ def _validate_pair(self, pair: str, ticker: Ticker | None) -> bool:
168167
if self._max_price != 0:
169168
if price > self._max_price:
170169
self.log_once(
171-
f"Removed {pair} from whitelist, "
172-
f"because last price > {self._max_price:.8f}",
170+
f"Removed {pair} from whitelist, because last price > {self._max_price:.8f}",
173171
logger.info,
174172
)
175173
return False

freqtrade/plugins/pairlist/RemotePairList.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,12 @@ def __init__(self, *args, **kwargs) -> None:
5858

5959
if self._mode not in ["whitelist", "blacklist"]:
6060
raise OperationalException(
61-
"`mode` not configured correctly. Supported Modes " 'are "whitelist","blacklist"'
61+
'`mode` not configured correctly. Supported Modes are "whitelist","blacklist"'
6262
)
6363

6464
if self._processing_mode not in ["filter", "append"]:
6565
raise OperationalException(
66-
"`processing_mode` not configured correctly. Supported Modes "
67-
'are "filter","append"'
66+
'`processing_mode` not configured correctly. Supported Modes are "filter","append"'
6867
)
6968

7069
if self._pairlist_pos == 0 and self._mode == "blacklist":

freqtrade/plugins/pairlist/SpreadFilter.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def short_desc(self) -> str:
4141
Short whitelist method description - used for startup-messages
4242
"""
4343
return (
44-
f"{self.name} - Filtering pairs with ask/bid diff above "
45-
f"{self._max_spread_ratio:.2%}."
44+
f"{self.name} - Filtering pairs with ask/bid diff above {self._max_spread_ratio:.2%}."
4645
)
4746

4847
@staticmethod

freqtrade/rpc/api_server/ws/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# isort: off
2-
from freqtrade.rpc.api_server.ws.types import WebSocketType # noqa: F401
2+
from freqtrade.rpc.api_server.ws.ws_types import WebSocketType # noqa: F401
33
from freqtrade.rpc.api_server.ws.proxy import WebSocketProxy # noqa: F401
44
from freqtrade.rpc.api_server.ws.serializer import HybridJSONWebSocketSerializer # noqa: F401
55
from freqtrade.rpc.api_server.ws.channel import WebSocketChannel # noqa: F401

freqtrade/rpc/api_server/ws/channel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
HybridJSONWebSocketSerializer,
1616
WebSocketSerializer,
1717
)
18-
from freqtrade.rpc.api_server.ws.types import WebSocketType
18+
from freqtrade.rpc.api_server.ws.ws_types import WebSocketType
1919
from freqtrade.rpc.api_server.ws_schemas import WSMessageSchemaType
2020

2121

freqtrade/rpc/api_server/ws/proxy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from fastapi import WebSocket as FastAPIWebSocket
44
from websockets.asyncio.client import ClientConnection as WebSocket
55

6-
from freqtrade.rpc.api_server.ws.types import WebSocketType
6+
from freqtrade.rpc.api_server.ws.ws_types import WebSocketType
77

88

99
class WebSocketProxy:
File renamed without changes.

freqtrade/rpc/webhook.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ def send_msg(self, msg: RPCSendMsg) -> None:
9494
self._send_msg(payload)
9595
except KeyError as exc:
9696
logger.exception(
97-
"Problem calling Webhook. Please check your webhook configuration. "
98-
"Exception: %s",
97+
"Problem calling Webhook. Please check your webhook configuration. Exception: %s",
9998
exc,
10099
)
101100

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-r docs/requirements-docs.txt
88

99
coveralls==4.0.1
10-
ruff==0.8.6
10+
ruff==0.9.1
1111
mypy==1.14.1
1212
pre-commit==4.0.1
1313
pytest==8.3.4

tests/commands/test_startup_time.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ def test_startup_time():
1212
start = time.time()
1313
subprocess.run(["freqtrade", "-h"])
1414
elapsed = time.time() - start
15-
assert (
16-
elapsed < MAXIMUM_STARTUP_TIME
17-
), "The startup time is too long, try to use lazy import in the command entry function"
15+
assert elapsed < MAXIMUM_STARTUP_TIME, (
16+
"The startup time is too long, try to use lazy import in the command entry function"
17+
)

tests/data/test_converter.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ def test_ohlcv_fill_up_missing_data(testdatadir, caplog):
120120
assert (data.columns == data2.columns).all()
121121

122122
assert log_has_re(
123-
f"Missing data fillup for UNITTEST/BTC, 1m: before: "
124-
f"{len(data)} - after: {len(data2)}.*",
123+
f"Missing data fillup for UNITTEST/BTC, 1m: before: {len(data)} - after: {len(data2)}.*",
125124
caplog,
126125
)
127126

tests/data/test_converter_orderflow.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ def test_analyze_with_orderflow(
556556
assert col in df2.columns, f"Round2: Column {col} not found in df.columns"
557557

558558
if col not in ("stacked_imbalances_bid", "stacked_imbalances_ask"):
559-
assert (
560-
df2[col].count() == 5
561-
), f"Round2: Column {col} has {df2[col].count()} non-NaN values"
559+
assert df2[col].count() == 5, (
560+
f"Round2: Column {col} has {df2[col].count()} non-NaN values"
561+
)
562562

563563
lastval_trade2 = df2.at[len(df2) - 1, "trades"]
564564
assert isinstance(lastval_trade2, list)

tests/data/test_history.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_load_data_30min_timeframe(caplog, testdatadir) -> None:
6464
ld = load_pair_history(pair="UNITTEST/BTC", timeframe="30m", datadir=testdatadir)
6565
assert isinstance(ld, DataFrame)
6666
assert not log_has(
67-
'Download history data for pair: "UNITTEST/BTC", timeframe: 30m ' "and store in None.",
67+
'Download history data for pair: "UNITTEST/BTC", timeframe: 30m and store in None.',
6868
caplog,
6969
)
7070

@@ -86,7 +86,7 @@ def test_load_data_1min_timeframe(ohlcv_history, mocker, caplog, testdatadir) ->
8686
load_data(datadir=testdatadir, timeframe="1m", pairs=["UNITTEST/BTC"])
8787
assert file.is_file()
8888
assert not log_has(
89-
'Download history data for pair: "UNITTEST/BTC", interval: 1m ' "and store in None.", caplog
89+
'Download history data for pair: "UNITTEST/BTC", interval: 1m and store in None.', caplog
9090
)
9191

9292

@@ -96,7 +96,7 @@ def test_load_data_mark(ohlcv_history, mocker, caplog, testdatadir) -> None:
9696
load_data(datadir=testdatadir, timeframe="1h", pairs=["UNITTEST/BTC"], candle_type="mark")
9797
assert file.is_file()
9898
assert not log_has(
99-
'Download history data for pair: "UNITTEST/USDT:USDT", interval: 1m ' "and store in None.",
99+
'Download history data for pair: "UNITTEST/USDT:USDT", interval: 1m and store in None.',
100100
caplog,
101101
)
102102

tests/exchange/test_binance.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test__get_params_binance(default_conf, mocker, side, order_type, time_in_for
4545
)
4646
def test_create_stoploss_order_binance(default_conf, mocker, limitratio, expected, side, trademode):
4747
api_mock = MagicMock()
48-
order_id = f"test_prod_buy_{randint(0, 10 ** 6)}"
48+
order_id = f"test_prod_buy_{randint(0, 10**6)}"
4949
order_type = "stop_loss_limit" if trademode == TradingMode.SPOT else "stop"
5050

5151
api_mock.create_order = MagicMock(return_value={"id": order_id, "info": {"foo": "bar"}})

0 commit comments

Comments
 (0)