Skip to content

Commit 9f436dc

Browse files
committed
chore: fix RUF043 violations
1 parent 95a710d commit 9f436dc

15 files changed

+51
-46
lines changed

tests/commands/test_commands.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,9 @@ def test_start_new_strategy_no_arg():
658658
args = [
659659
"new-strategy",
660660
]
661-
with pytest.raises(OperationalException, match="`new-strategy` requires --strategy to be set."):
661+
with pytest.raises(
662+
OperationalException, match=r"`new-strategy` requires --strategy to be set\."
663+
):
662664
start_new_strategy(get_args(args))
663665

664666

@@ -803,7 +805,7 @@ def test_get_ui_download_url_direct(mocker):
803805
assert last_version == "0.0.1"
804806
assert x == "http://download1.zip"
805807

806-
with pytest.raises(ValueError, match="UI-Version not found."):
808+
with pytest.raises(ValueError, match=r"UI-Version not found\."):
807809
x, last_version = get_ui_download_url("0.0.3", False)
808810

809811

@@ -1650,15 +1652,15 @@ def fake_iterator(*args, **kwargs):
16501652
pargs = get_args(args)
16511653
pargs["config"] = None
16521654
with pytest.raises(
1653-
OperationalException, match="The index of the epoch to show should be greater than -4."
1655+
OperationalException, match=r"The index of the epoch to show should be greater than -4\."
16541656
):
16551657
start_hyperopt_show(pargs)
16561658

16571659
args = ["hyperopt-show", "--best", "-n", "4"]
16581660
pargs = get_args(args)
16591661
pargs["config"] = None
16601662
with pytest.raises(
1661-
OperationalException, match="The index of the epoch to show should be less than 4."
1663+
OperationalException, match=r"The index of the epoch to show should be less than 4\."
16621664
):
16631665
start_hyperopt_show(pargs)
16641666

@@ -2032,5 +2034,7 @@ def test_start_edge():
20322034
]
20332035

20342036
pargs = get_args(args)
2035-
with pytest.raises(OperationalException, match="The Edge module has been deprecated in 2023.9"):
2037+
with pytest.raises(
2038+
OperationalException, match=r"The Edge module has been deprecated in 2023\.9"
2039+
):
20362040
start_edge(pargs)

tests/data/test_btanalysis.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_get_latest_hyperopt_file(testdatadir):
7575
# Test with absolute path
7676
with pytest.raises(
7777
OperationalException,
78-
match="--hyperopt-filename expects only the filename, not an absolute path.",
78+
match=r"--hyperopt-filename expects only the filename, not an absolute path\.",
7979
):
8080
get_latest_hyperopt_file(str(testdatadir.parent), str(testdatadir.parent))
8181

@@ -344,7 +344,7 @@ def test_create_cum_profit1(testdatadir):
344344
assert cum_profits.iloc[0]["cum_profits"] == 0
345345
assert pytest.approx(cum_profits.iloc[-1]["cum_profits"]) == 9.0225563e-05
346346

347-
with pytest.raises(ValueError, match="Trade dataframe empty."):
347+
with pytest.raises(ValueError, match=r"Trade dataframe empty\."):
348348
create_cum_profit(
349349
df.set_index("date"),
350350
bt_data[bt_data["pair"] == "NOTAPAIR"],
@@ -369,10 +369,10 @@ def test_calculate_max_drawdown(testdatadir):
369369
underwater = calculate_underwater(bt_data)
370370
assert isinstance(underwater, DataFrame)
371371

372-
with pytest.raises(ValueError, match="Trade dataframe empty."):
372+
with pytest.raises(ValueError, match=r"Trade dataframe empty\."):
373373
calculate_max_drawdown(DataFrame())
374374

375-
with pytest.raises(ValueError, match="Trade dataframe empty."):
375+
with pytest.raises(ValueError, match=r"Trade dataframe empty\."):
376376
calculate_underwater(DataFrame())
377377

378378

@@ -391,7 +391,7 @@ def test_calculate_csum(testdatadir):
391391
assert csum_min1 == csum_min + 5
392392
assert csum_max1 == csum_max + 5
393393

394-
with pytest.raises(ValueError, match="Trade dataframe empty."):
394+
with pytest.raises(ValueError, match=r"Trade dataframe empty\."):
395395
csum_min, csum_max = calculate_csum(DataFrame())
396396

397397

tests/data/test_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_ohlcv_to_dataframe(ohlcv_history_list, caplog):
4949

5050
def test_trades_to_ohlcv(trades_history_df, caplog):
5151
caplog.set_level(logging.DEBUG)
52-
with pytest.raises(ValueError, match="Trade-list empty."):
52+
with pytest.raises(ValueError, match=r"Trade-list empty\."):
5353
trades_to_ohlcv(pd.DataFrame(columns=trades_history_df.columns), "1m")
5454

5555
df = trades_to_ohlcv(trades_history_df, "1m")

tests/exchange/test_exchange.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ def test_validate_pricing(default_conf, mocker):
859859
default_conf["exchange"]["name"] = "binance"
860860
ExchangeResolver.load_exchange(default_conf)
861861
has.update({"fetchTicker": False})
862-
with pytest.raises(OperationalException, match="Ticker pricing not available for .*"):
862+
with pytest.raises(OperationalException, match=r"Ticker pricing not available for .*"):
863863
ExchangeResolver.load_exchange(default_conf)
864864

865865
has.update({"fetchTicker": True})
@@ -868,7 +868,7 @@ def test_validate_pricing(default_conf, mocker):
868868
ExchangeResolver.load_exchange(default_conf)
869869
has.update({"fetchL2OrderBook": False})
870870

871-
with pytest.raises(OperationalException, match="Orderbook not available for .*"):
871+
with pytest.raises(OperationalException, match=r"Orderbook not available for .*"):
872872
ExchangeResolver.load_exchange(default_conf)
873873

874874
has.update({"fetchL2OrderBook": True})
@@ -877,7 +877,7 @@ def test_validate_pricing(default_conf, mocker):
877877
default_conf["trading_mode"] = TradingMode.FUTURES
878878
default_conf["margin_mode"] = MarginMode.ISOLATED
879879

880-
with pytest.raises(OperationalException, match="Ticker pricing not available for .*"):
880+
with pytest.raises(OperationalException, match=r"Ticker pricing not available for .*"):
881881
ExchangeResolver.load_exchange(default_conf)
882882

883883

@@ -3556,7 +3556,7 @@ def test_get_historic_trades_notsupported(
35563556
pair = "ETH/BTC"
35573557

35583558
with pytest.raises(
3559-
OperationalException, match="This exchange does not support downloading Trades."
3559+
OperationalException, match=r"This exchange does not support downloading Trades\."
35603560
):
35613561
exchange.get_historic_trades(pair, since=trades_history[0][0], until=trades_history[-1][0])
35623562

@@ -4442,7 +4442,7 @@ def test_get_markets(
44424442
def test_get_markets_error(default_conf, mocker):
44434443
ex = get_patched_exchange(mocker, default_conf)
44444444
mocker.patch(f"{EXMS}.markets", PropertyMock(return_value=None))
4445-
with pytest.raises(OperationalException, match="Markets were not loaded."):
4445+
with pytest.raises(OperationalException, match=r"Markets were not loaded\."):
44464446
ex.get_markets("LTC", "USDT", True, False)
44474447

44484448

@@ -5243,7 +5243,7 @@ def test__fetch_and_calculate_funding_fees(
52435243
# Return empty "refresh_latest"
52445244
mocker.patch(f"{EXMS}.refresh_latest_ohlcv", return_value={})
52455245
ex = get_patched_exchange(mocker, default_conf, api_mock, exchange=exchange)
5246-
with pytest.raises(ExchangeError, match="Could not find funding rates."):
5246+
with pytest.raises(ExchangeError, match=r"Could not find funding rates\."):
52475247
ex._fetch_and_calculate_funding_fees(
52485248
pair="ADA/USDT:USDT", amount=amount, is_short=False, open_date=d1, close_date=d2
52495249
)

tests/freqtradebot/test_freqtradebot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ def test_execute_entry(
986986
# Fail to get price...
987987
mocker.patch(f"{EXMS}.get_rate", MagicMock(return_value=0.0))
988988

989-
with pytest.raises(PricingError, match="Could not determine entry price."):
989+
with pytest.raises(PricingError, match=r"Could not determine entry price\."):
990990
freqtrade.execute_entry(pair, stake_amount, is_short=is_short)
991991

992992
# In case of custom entry price

tests/optimize/test_backtesting.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def get_timerange(input1):
444444

445445
backtesting = Backtesting(default_conf)
446446
backtesting._set_strategy(backtesting.strategylist[0])
447-
with pytest.raises(OperationalException, match="No data found. Terminating."):
447+
with pytest.raises(OperationalException, match=r"No data found. Terminating\."):
448448
backtesting.start()
449449

450450

@@ -465,7 +465,7 @@ def test_backtesting_no_pair_left(default_conf, mocker) -> None:
465465
default_conf["export"] = "none"
466466
default_conf["timerange"] = "20180101-20180102"
467467

468-
with pytest.raises(OperationalException, match="No pair in whitelist."):
468+
with pytest.raises(OperationalException, match=r"No pair in whitelist\."):
469469
Backtesting(default_conf)
470470

471471
default_conf.update(
@@ -476,7 +476,7 @@ def test_backtesting_no_pair_left(default_conf, mocker) -> None:
476476
)
477477

478478
with pytest.raises(
479-
OperationalException, match="Detail timeframe must be smaller than strategy timeframe."
479+
OperationalException, match=r"Detail timeframe must be smaller than strategy timeframe\."
480480
):
481481
Backtesting(default_conf)
482482

@@ -517,7 +517,7 @@ def test_backtesting_pairlist_list(default_conf, mocker, tickers) -> None:
517517
default_conf["strategy_list"] = [CURRENT_TEST_STRATEGY, "StrategyTestV2"]
518518
with pytest.raises(
519519
OperationalException,
520-
match="PrecisionFilter not allowed for backtesting multiple strategies.",
520+
match=r"PrecisionFilter not allowed for backtesting multiple strategies\.",
521521
):
522522
Backtesting(default_conf)
523523

tests/optimize/test_hyperopt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def test_start_no_data(mocker, hyperopt_conf, tmp_path) -> None:
280280
"5",
281281
]
282282
pargs = get_args(args)
283-
with pytest.raises(OperationalException, match="No data found. Terminating."):
283+
with pytest.raises(OperationalException, match=r"No data found. Terminating\."):
284284
start_hyperopt(pargs)
285285

286286
# Cleanup since that failed hyperopt start leaves a lockfile.
@@ -1127,7 +1127,7 @@ def test_in_strategy_auto_hyperopt(mocker, hyperopt_conf, tmp_path, fee) -> None
11271127
assert opt.backtesting.strategy.max_open_trades != 1
11281128

11291129
opt.custom_hyperopt.generate_estimator = lambda *args, **kwargs: "ET1"
1130-
with pytest.raises(OperationalException, match="Optuna Sampler ET1 not supported."):
1130+
with pytest.raises(OperationalException, match=r"Optuna Sampler ET1 not supported\."):
11311131
opt.get_optimizer(42)
11321132

11331133

tests/optimize/test_hyperoptloss.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
def test_hyperoptlossresolver_noname(default_conf):
1212
with pytest.raises(
1313
OperationalException,
14-
match="No Hyperopt loss set. Please use `--hyperopt-loss` to specify "
15-
"the Hyperopt-Loss class to use.",
14+
match=r"No Hyperopt loss set. Please use `--hyperopt-loss` to specify "
15+
r"the Hyperopt-Loss class to use\.",
1616
):
1717
HyperOptLossResolver.load_hyperoptloss(default_conf)
1818

tests/plugins/test_pairlist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ def test_rangestabilityfilter_checks(mocker, default_conf, markets, tickers):
16691669

16701670
with pytest.raises(
16711671
OperationalException,
1672-
match="RangeStabilityFilter requires sort_direction to be either None.*",
1672+
match=r"RangeStabilityFilter requires sort_direction to be either None\.*",
16731673
):
16741674
get_patched_freqtradebot(mocker, default_conf)
16751675

@@ -2526,7 +2526,7 @@ def test_MarketCapPairList_exceptions(mocker, default_conf_usdt, caplog):
25262526
}
25272527
]
25282528
with pytest.raises(
2529-
OperationalException, match="Category layer250 not in coingecko category list."
2529+
OperationalException, match=r"Category layer250 not in coingecko category list\."
25302530
):
25312531
PairListManager(exchange, default_conf_usdt)
25322532

tests/plugins/test_remotepairlist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_fetch_pairlist_mock_response_html(mocker, rpl_config):
8282
exchange, pairlistmanager, rpl_config, rpl_config["pairlists"][0], 0
8383
)
8484

85-
with pytest.raises(OperationalException, match="RemotePairList is not of type JSON."):
85+
with pytest.raises(OperationalException, match=r"RemotePairList is not of type JSON\."):
8686
remote_pairlist.fetch_pairlist()
8787

8888

0 commit comments

Comments
 (0)