Improve some typing

This commit is contained in:
Matthias 2022-05-25 20:43:43 +02:00
parent 3e66275c98
commit 537d10c627
5 changed files with 11 additions and 5 deletions

View File

@ -490,7 +490,8 @@ class Configuration:
if not pairs_file.exists(): if not pairs_file.exists():
raise OperationalException(f'No pairs file found with path "{pairs_file}".') raise OperationalException(f'No pairs file found with path "{pairs_file}".')
config['pairs'] = load_file(pairs_file) config['pairs'] = load_file(pairs_file)
config['pairs'].sort() if isinstance(config['pairs'], list):
config['pairs'].sort()
return return
if 'config' in self.args and self.args['config']: if 'config' in self.args and self.args['config']:
@ -501,5 +502,5 @@ class Configuration:
pairs_file = config['datadir'] / 'pairs.json' pairs_file = config['datadir'] / 'pairs.json'
if pairs_file.exists(): if pairs_file.exists():
config['pairs'] = load_file(pairs_file) config['pairs'] = load_file(pairs_file)
if 'pairs' in config: if 'pairs' in config and isinstance(config['pairs'], list):
config['pairs'].sort() config['pairs'].sort()

View File

@ -15,7 +15,7 @@ def create_datadir(config: Dict[str, Any], datadir: Optional[str] = None) -> Pat
folder = Path(datadir) if datadir else Path(f"{config['user_data_dir']}/data") folder = Path(datadir) if datadir else Path(f"{config['user_data_dir']}/data")
if not datadir: if not datadir:
# set datadir # set datadir
exchange_name = config.get('exchange', {}).get('name').lower() exchange_name = config.get('exchange', {}).get('name', '').lower()
folder = folder.joinpath(exchange_name) folder = folder.joinpath(exchange_name)
if not folder.is_dir(): if not folder.is_dir():

View File

@ -69,7 +69,7 @@ class HyperStrategyMixin:
@classmethod @classmethod
def detect_all_parameters(cls) -> Dict: def detect_all_parameters(cls) -> Dict:
""" Detect all parameters and return them as a list""" """ Detect all parameters and return them as a list"""
params: Dict = { params: Dict[str, Any] = {
'buy': list(cls.detect_parameters('buy')), 'buy': list(cls.detect_parameters('buy')),
'sell': list(cls.detect_parameters('sell')), 'sell': list(cls.detect_parameters('sell')),
'protection': list(cls.detect_parameters('protection')), 'protection': list(cls.detect_parameters('protection')),
@ -148,7 +148,7 @@ class HyperStrategyMixin:
""" """
Returns list of Parameters that are not part of the current optimize job Returns list of Parameters that are not part of the current optimize job
""" """
params = { params: Dict[str, Dict] = {
'buy': {}, 'buy': {},
'sell': {}, 'sell': {},
'protection': {}, 'protection': {},

View File

@ -97,6 +97,8 @@ class NumericParameter(BaseParameter):
class IntParameter(NumericParameter): class IntParameter(NumericParameter):
default: int default: int
value: int value: int
low: int
high: int
def __init__(self, low: Union[int, Sequence[int]], high: Optional[int] = None, *, default: int, def __init__(self, low: Union[int, Sequence[int]], high: Optional[int] = None, *, default: int,
space: Optional[str] = None, optimize: bool = True, load: bool = True, **kwargs): space: Optional[str] = None, optimize: bool = True, load: bool = True, **kwargs):

View File

@ -50,3 +50,6 @@ exclude = [
"build_helpers/*.py", "build_helpers/*.py",
] ]
ignore = ["freqtrade/vendor/**"] ignore = ["freqtrade/vendor/**"]
# Align pyright to mypy config
strictParameterNoneValue = false