Skip to content

Commit

Permalink
Merge pull request freqtrade#10748 from freqtrade/maint/bump_ruff_min…
Browse files Browse the repository at this point in the history
…python

Bump ruff target version to 3.9
  • Loading branch information
xmatthias authored Oct 6, 2024
2 parents b885c3d + 78e9eac commit e703fec
Show file tree
Hide file tree
Showing 180 changed files with 1,204 additions and 1,216 deletions.
6 changes: 3 additions & 3 deletions freqtrade/commands/analyze_commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from pathlib import Path
from typing import Any, Dict
from typing import Any

from freqtrade.enums import RunMode
from freqtrade.exceptions import ConfigurationError, OperationalException
Expand All @@ -9,7 +9,7 @@
logger = logging.getLogger(__name__)


def setup_analyze_configuration(args: Dict[str, Any], method: RunMode) -> Dict[str, Any]:
def setup_analyze_configuration(args: dict[str, Any], method: RunMode) -> dict[str, Any]:
"""
Prepare the configuration for the entry/exit reason analysis module
:param args: Cli args from Arguments()
Expand Down Expand Up @@ -48,7 +48,7 @@ def setup_analyze_configuration(args: Dict[str, Any], method: RunMode) -> Dict[s
return config


def start_analysis_entries_exits(args: Dict[str, Any]) -> None:
def start_analysis_entries_exits(args: dict[str, Any]) -> None:
"""
Start analysis script
:param args: Cli args from Arguments()
Expand Down
10 changes: 5 additions & 5 deletions freqtrade/commands/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from argparse import ArgumentParser, Namespace, _ArgumentGroup
from functools import partial
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
from typing import Any, Optional, Union

from freqtrade.commands.cli_options import AVAILABLE_CLI_OPTIONS
from freqtrade.constants import DEFAULT_CONFIG
Expand All @@ -23,7 +23,7 @@

ARGS_TRADE = ["db_url", "sd_notify", "dry_run", "dry_run_wallet", "fee"]

ARGS_WEBSERVER: List[str] = []
ARGS_WEBSERVER: list[str] = []

ARGS_COMMON_OPTIMIZE = [
"timeframe",
Expand Down Expand Up @@ -277,11 +277,11 @@ class Arguments:
Arguments Class. Manage the arguments received by the cli
"""

def __init__(self, args: Optional[List[str]]) -> None:
def __init__(self, args: Optional[list[str]]) -> None:
self.args = args
self._parsed_arg: Optional[Namespace] = None

def get_parsed_arg(self) -> Dict[str, Any]:
def get_parsed_arg(self) -> dict[str, Any]:
"""
Return the list of arguments
:return: List[str] List of arguments
Expand Down Expand Up @@ -322,7 +322,7 @@ def _parse_args(self) -> Namespace:
return parsed_arg

def _build_args(
self, optionlist: List[str], parser: Union[ArgumentParser, _ArgumentGroup]
self, optionlist: list[str], parser: Union[ArgumentParser, _ArgumentGroup]
) -> None:
for val in optionlist:
opt = AVAILABLE_CLI_OPTIONS[val]
Expand Down
6 changes: 3 additions & 3 deletions freqtrade/commands/build_config_commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from pathlib import Path
from typing import Any, Dict
from typing import Any

from freqtrade.enums import RunMode
from freqtrade.exceptions import OperationalException
Expand All @@ -9,7 +9,7 @@
logger = logging.getLogger(__name__)


def start_new_config(args: Dict[str, Any]) -> None:
def start_new_config(args: dict[str, Any]) -> None:
"""
Create a new strategy from a template
Asking the user questions to fill out the template accordingly.
Expand Down Expand Up @@ -37,7 +37,7 @@ def start_new_config(args: Dict[str, Any]) -> None:
deploy_new_config(config_path, selections)


def start_show_config(args: Dict[str, Any]) -> None:
def start_show_config(args: dict[str, Any]) -> None:
from freqtrade.configuration import sanitize_config
from freqtrade.configuration.config_setup import setup_utils_configuration

Expand Down
12 changes: 6 additions & 6 deletions freqtrade/commands/data_commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import sys
from collections import defaultdict
from typing import Any, Dict
from typing import Any

from freqtrade.constants import DATETIME_PRINT_FORMAT, DL_DATA_TIMEFRAMES, Config
from freqtrade.enums import CandleType, RunMode, TradingMode
Expand All @@ -26,7 +26,7 @@ def _check_data_config_download_sanity(config: Config) -> None:
)


def start_download_data(args: Dict[str, Any]) -> None:
def start_download_data(args: dict[str, Any]) -> None:
"""
Download data (former download_backtest_data.py script)
"""
Expand All @@ -44,7 +44,7 @@ def start_download_data(args: Dict[str, Any]) -> None:
sys.exit("SIGINT received, aborting ...")


def start_convert_trades(args: Dict[str, Any]) -> None:
def start_convert_trades(args: dict[str, Any]) -> None:
from freqtrade.configuration import TimeRange, setup_utils_configuration
from freqtrade.data.converter import convert_trades_to_ohlcv
from freqtrade.resolvers import ExchangeResolver
Expand Down Expand Up @@ -87,7 +87,7 @@ def start_convert_trades(args: Dict[str, Any]) -> None:
)


def start_convert_data(args: Dict[str, Any], ohlcv: bool = True) -> None:
def start_convert_data(args: dict[str, Any], ohlcv: bool = True) -> None:
"""
Convert data from one format to another
"""
Expand All @@ -113,7 +113,7 @@ def start_convert_data(args: Dict[str, Any], ohlcv: bool = True) -> None:
)


def start_list_data(args: Dict[str, Any]) -> None:
def start_list_data(args: dict[str, Any]) -> None:
"""
List available OHLCV data
"""
Expand Down Expand Up @@ -179,7 +179,7 @@ def start_list_data(args: Dict[str, Any]) -> None:
)


def start_list_trades_data(args: Dict[str, Any]) -> None:
def start_list_trades_data(args: dict[str, Any]) -> None:
"""
List available Trades data
"""
Expand Down
4 changes: 2 additions & 2 deletions freqtrade/commands/db_commands.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import logging
from typing import Any, Dict
from typing import Any

from freqtrade.enums import RunMode


logger = logging.getLogger(__name__)


def start_convert_db(args: Dict[str, Any]) -> None:
def start_convert_db(args: dict[str, Any]) -> None:
from sqlalchemy import func, select
from sqlalchemy.orm import make_transient

Expand Down
8 changes: 4 additions & 4 deletions freqtrade/commands/deploy_commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import sys
from pathlib import Path
from typing import Any, Dict
from typing import Any

from freqtrade.constants import USERPATH_STRATEGIES
from freqtrade.enums import RunMode
Expand All @@ -15,7 +15,7 @@
req_timeout = 30


def start_create_userdir(args: Dict[str, Any]) -> None:
def start_create_userdir(args: dict[str, Any]) -> None:
"""
Create "user_data" directory to contain user data strategies, hyperopt, ...)
:param args: Cli args from Arguments()
Expand Down Expand Up @@ -80,7 +80,7 @@ def deploy_new_strategy(strategy_name: str, strategy_path: Path, subtemplate: st
strategy_path.write_text(strategy_text)


def start_new_strategy(args: Dict[str, Any]) -> None:
def start_new_strategy(args: dict[str, Any]) -> None:
from freqtrade.configuration import setup_utils_configuration

config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
Expand All @@ -99,7 +99,7 @@ def start_new_strategy(args: Dict[str, Any]) -> None:
raise ConfigurationError("`new-strategy` requires --strategy to be set.")


def start_install_ui(args: Dict[str, Any]) -> None:
def start_install_ui(args: dict[str, Any]) -> None:
from freqtrade.commands.deploy_ui import (
clean_ui_subdir,
download_and_install_ui,
Expand Down
4 changes: 2 additions & 2 deletions freqtrade/commands/deploy_ui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from pathlib import Path
from typing import Optional, Tuple
from typing import Optional

import requests

Expand Down Expand Up @@ -52,7 +52,7 @@ def download_and_install_ui(dest_folder: Path, dl_url: str, version: str):
f.write(version)


def get_ui_download_url(version: Optional[str] = None) -> Tuple[str, str]:
def get_ui_download_url(version: Optional[str] = None) -> tuple[str, str]:
base_url = "https://api.github.com/repos/freqtrade/frequi/"
# Get base UI Repo path

Expand Down
6 changes: 3 additions & 3 deletions freqtrade/commands/hyperopt_commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from operator import itemgetter
from typing import Any, Dict
from typing import Any

from freqtrade.enums import RunMode
from freqtrade.exceptions import OperationalException
Expand All @@ -9,7 +9,7 @@
logger = logging.getLogger(__name__)


def start_hyperopt_list(args: Dict[str, Any]) -> None:
def start_hyperopt_list(args: dict[str, Any]) -> None:
"""
List hyperopt epochs previously evaluated
"""
Expand Down Expand Up @@ -56,7 +56,7 @@ def start_hyperopt_list(args: Dict[str, Any]) -> None:
HyperoptTools.export_csv_file(config, epochs, export_csv)


def start_hyperopt_show(args: Dict[str, Any]) -> None:
def start_hyperopt_show(args: dict[str, Any]) -> None:
"""
Show details of a hyperopt epoch previously evaluated
"""
Expand Down
20 changes: 10 additions & 10 deletions freqtrade/commands/list_commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import csv
import logging
import sys
from typing import Any, Dict, List, Union
from typing import Any, Union

from freqtrade.enums import RunMode
from freqtrade.exceptions import ConfigurationError, OperationalException
Expand All @@ -11,7 +11,7 @@
logger = logging.getLogger(__name__)


def start_list_exchanges(args: Dict[str, Any]) -> None:
def start_list_exchanges(args: dict[str, Any]) -> None:
"""
Print available exchanges
:param args: Cli args from Arguments()
Expand All @@ -23,7 +23,7 @@ def start_list_exchanges(args: Dict[str, Any]) -> None:

from freqtrade.exchange import list_available_exchanges

available_exchanges: List[ValidExchangesType] = list_available_exchanges(
available_exchanges: list[ValidExchangesType] = list_available_exchanges(
args["list_exchanges_all"]
)

Expand Down Expand Up @@ -81,13 +81,13 @@ def start_list_exchanges(args: Dict[str, Any]) -> None:
console.print(table)


def _print_objs_tabular(objs: List, print_colorized: bool) -> None:
def _print_objs_tabular(objs: list, print_colorized: bool) -> None:
from rich.console import Console
from rich.table import Table
from rich.text import Text

names = [s["name"] for s in objs]
objs_to_print: List[Dict[str, Union[Text, str]]] = [
objs_to_print: list[dict[str, Union[Text, str]]] = [
{
"name": Text(s["name"] if s["name"] else "--"),
"location": s["location_rel"],
Expand Down Expand Up @@ -125,7 +125,7 @@ def _print_objs_tabular(objs: List, print_colorized: bool) -> None:
console.print(table)


def start_list_strategies(args: Dict[str, Any]) -> None:
def start_list_strategies(args: dict[str, Any]) -> None:
"""
Print files with Strategy custom classes available in the directory
"""
Expand All @@ -151,7 +151,7 @@ def start_list_strategies(args: Dict[str, Any]) -> None:
_print_objs_tabular(strategy_objs, config.get("print_colorized", False))


def start_list_freqAI_models(args: Dict[str, Any]) -> None:
def start_list_freqAI_models(args: dict[str, Any]) -> None:
"""
Print files with FreqAI models custom classes available in the directory
"""
Expand All @@ -169,7 +169,7 @@ def start_list_freqAI_models(args: Dict[str, Any]) -> None:
_print_objs_tabular(model_objs, config.get("print_colorized", False))


def start_list_timeframes(args: Dict[str, Any]) -> None:
def start_list_timeframes(args: dict[str, Any]) -> None:
"""
Print timeframes available on Exchange
"""
Expand All @@ -192,7 +192,7 @@ def start_list_timeframes(args: Dict[str, Any]) -> None:
)


def start_list_markets(args: Dict[str, Any], pairs_only: bool = False) -> None:
def start_list_markets(args: dict[str, Any], pairs_only: bool = False) -> None:
"""
Print pairs/markets on the exchange
:param args: Cli args from Arguments()
Expand Down Expand Up @@ -312,7 +312,7 @@ def start_list_markets(args: Dict[str, Any], pairs_only: bool = False) -> None:
print(f"{summary_str}.")


def start_show_trades(args: Dict[str, Any]) -> None:
def start_show_trades(args: dict[str, Any]) -> None:
"""
Show trades
"""
Expand Down
16 changes: 8 additions & 8 deletions freqtrade/commands/optimize_commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Any, Dict
from typing import Any

from freqtrade import constants
from freqtrade.enums import RunMode
Expand All @@ -9,7 +9,7 @@
logger = logging.getLogger(__name__)


def setup_optimize_configuration(args: Dict[str, Any], method: RunMode) -> Dict[str, Any]:
def setup_optimize_configuration(args: dict[str, Any], method: RunMode) -> dict[str, Any]:
"""
Prepare the configuration for the Hyperopt module
:param args: Cli args from Arguments()
Expand Down Expand Up @@ -42,7 +42,7 @@ def setup_optimize_configuration(args: Dict[str, Any], method: RunMode) -> Dict[
return config


def start_backtesting(args: Dict[str, Any]) -> None:
def start_backtesting(args: dict[str, Any]) -> None:
"""
Start Backtesting script
:param args: Cli args from Arguments()
Expand All @@ -61,7 +61,7 @@ def start_backtesting(args: Dict[str, Any]) -> None:
backtesting.start()


def start_backtesting_show(args: Dict[str, Any]) -> None:
def start_backtesting_show(args: dict[str, Any]) -> None:
"""
Show previous backtest result
"""
Expand All @@ -78,7 +78,7 @@ def start_backtesting_show(args: Dict[str, Any]) -> None:
show_sorted_pairlist(config, results)


def start_hyperopt(args: Dict[str, Any]) -> None:
def start_hyperopt(args: dict[str, Any]) -> None:
"""
Start hyperopt script
:param args: Cli args from Arguments()
Expand Down Expand Up @@ -123,7 +123,7 @@ def start_hyperopt(args: Dict[str, Any]) -> None:
# Same in Edge and Backtesting start() functions.


def start_edge(args: Dict[str, Any]) -> None:
def start_edge(args: dict[str, Any]) -> None:
"""
Start Edge script
:param args: Cli args from Arguments()
Expand All @@ -140,7 +140,7 @@ def start_edge(args: Dict[str, Any]) -> None:
edge_cli.start()


def start_lookahead_analysis(args: Dict[str, Any]) -> None:
def start_lookahead_analysis(args: dict[str, Any]) -> None:
"""
Start the backtest bias tester script
:param args: Cli args from Arguments()
Expand All @@ -153,7 +153,7 @@ def start_lookahead_analysis(args: Dict[str, Any]) -> None:
LookaheadAnalysisSubFunctions.start(config)


def start_recursive_analysis(args: Dict[str, Any]) -> None:
def start_recursive_analysis(args: dict[str, Any]) -> None:
"""
Start the backtest recursive tester script
:param args: Cli args from Arguments()
Expand Down
Loading

0 comments on commit e703fec

Please sign in to comment.