diff --git a/freqtrade/resolvers/exchange_resolver.py b/freqtrade/resolvers/exchange_resolver.py index c0c3c906b..9d5a0d557 100644 --- a/freqtrade/resolvers/exchange_resolver.py +++ b/freqtrade/resolvers/exchange_resolver.py @@ -4,7 +4,7 @@ This module loads custom exchanges import logging from inspect import isclass -from typing import Any, Dict, List, Optional +from typing import Any, Optional import freqtrade.exchange as exchanges from freqtrade.constants import Config, ExchangeConfig @@ -90,7 +90,7 @@ class ExchangeResolver(IResolver): @classmethod def search_all_objects( cls, config: Config, enum_failed: bool, recursive: bool = False - ) -> List[Dict[str, Any]]: + ) -> list[dict[str, Any]]: """ Searches for valid objects :param config: Config object diff --git a/freqtrade/resolvers/iresolver.py b/freqtrade/resolvers/iresolver.py index bac5c08a7..f6727ca97 100644 --- a/freqtrade/resolvers/iresolver.py +++ b/freqtrade/resolvers/iresolver.py @@ -8,8 +8,9 @@ import importlib.util import inspect import logging import sys +from collections.abc import Iterator from pathlib import Path -from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union +from typing import Any, Optional, Union from freqtrade.constants import Config from freqtrade.exceptions import OperationalException @@ -40,7 +41,7 @@ class IResolver: """ # Childclasses need to override this - object_type: Type[Any] + object_type: type[Any] object_type_str: str user_subdir: Optional[str] = None initial_search_path: Optional[Path] = None @@ -52,9 +53,9 @@ class IResolver: cls, config: Config, user_subdir: Optional[str] = None, - extra_dirs: Optional[List[str]] = None, - ) -> List[Path]: - abs_paths: List[Path] = [] + extra_dirs: Optional[list[str]] = None, + ) -> list[Path]: + abs_paths: list[Path] = [] if cls.initial_search_path: abs_paths.append(cls.initial_search_path) @@ -124,7 +125,7 @@ class IResolver: @classmethod def _search_object( cls, directory: Path, *, object_name: str, add_source: bool = False - ) -> Union[Tuple[Any, Path], Tuple[None, None]]: + ) -> Union[tuple[Any, Path], tuple[None, None]]: """ Search for the objectname in the given directory :param directory: relative or absolute directory path @@ -153,7 +154,7 @@ class IResolver: @classmethod def _load_object( - cls, paths: List[Path], *, object_name: str, add_source: bool = False, kwargs: Dict + cls, paths: list[Path], *, object_name: str, add_source: bool = False, kwargs: dict ) -> Optional[Any]: """ Try to load object from path list. @@ -188,7 +189,7 @@ class IResolver: :return: Object instance or None """ - extra_dirs: List[str] = [] + extra_dirs: list[str] = [] if extra_dir: extra_dirs.append(extra_dir) @@ -207,7 +208,7 @@ class IResolver: @classmethod def search_all_objects( cls, config: Config, enum_failed: bool, recursive: bool = False - ) -> List[Dict[str, Any]]: + ) -> list[dict[str, Any]]: """ Searches for valid objects :param config: Config object @@ -239,7 +240,7 @@ class IResolver: enum_failed: bool, recursive: bool = False, basedir: Optional[Path] = None, - ) -> List[Dict[str, Any]]: + ) -> list[dict[str, Any]]: """ Searches a directory for valid objects :param directory: Path to search @@ -249,7 +250,7 @@ class IResolver: :return: List of dicts containing 'name', 'class' and 'location' entries """ logger.debug(f"Searching for {cls.object_type.__name__} '{directory}'") - objects: List[Dict[str, Any]] = [] + objects: list[dict[str, Any]] = [] if not directory.is_dir(): logger.info(f"'{directory}' is not a directory, skipping.") return objects diff --git a/freqtrade/resolvers/protection_resolver.py b/freqtrade/resolvers/protection_resolver.py index 67b68f050..661791ace 100644 --- a/freqtrade/resolvers/protection_resolver.py +++ b/freqtrade/resolvers/protection_resolver.py @@ -4,7 +4,6 @@ This module load custom pairlists import logging from pathlib import Path -from typing import Dict from freqtrade.constants import Config from freqtrade.plugins.protections import IProtection @@ -26,7 +25,7 @@ class ProtectionResolver(IResolver): @staticmethod def load_protection( - protection_name: str, config: Config, protection_config: Dict + protection_name: str, config: Config, protection_config: dict ) -> IProtection: """ Load the protection with protection_name diff --git a/freqtrade/resolvers/strategy_resolver.py b/freqtrade/resolvers/strategy_resolver.py index 6cd0cef23..5ac1cb6f9 100644 --- a/freqtrade/resolvers/strategy_resolver.py +++ b/freqtrade/resolvers/strategy_resolver.py @@ -10,7 +10,7 @@ from base64 import urlsafe_b64decode from inspect import getfullargspec from os import walk from pathlib import Path -from typing import Any, List, Optional +from typing import Any, Optional from freqtrade.configuration.config_validation import validate_migrated_strategy_settings from freqtrade.constants import REQUIRED_ORDERTIF, REQUIRED_ORDERTYPES, USERPATH_STRATEGIES, Config @@ -256,7 +256,7 @@ class StrategyResolver(IResolver): :return: Strategy instance or None """ if config.get("recursive_strategy_search", False): - extra_dirs: List[str] = [ + extra_dirs: list[str] = [ path[0] for path in walk(f"{config['user_data_dir']}/{USERPATH_STRATEGIES}") ] # sub-directories else: