Always use config.json if it's available

This commit is contained in:
Matthias 2019-09-03 06:48:51 +02:00
parent f9c7a2cacb
commit 1b66f01ec0
2 changed files with 7 additions and 2 deletions

View File

@ -3,6 +3,7 @@ This module contains the argument manager class
""" """
import argparse import argparse
from typing import List, Optional from typing import List, Optional
from pathlib import Path
from freqtrade.configuration.cli_options import AVAILABLE_CLI_OPTIONS from freqtrade.configuration.cli_options import AVAILABLE_CLI_OPTIONS
from freqtrade import constants from freqtrade import constants
@ -73,11 +74,13 @@ class Arguments(object):
""" """
parsed_arg = self.parser.parse_args(self.args) parsed_arg = self.parser.parse_args(self.args)
# When no config is provided, but a config exists, use that configuration!
# Workaround issue in argparse with action='append' and default value # Workaround issue in argparse with action='append' and default value
# (see https://bugs.python.org/issue16399) # (see https://bugs.python.org/issue16399)
# Allow no-config for certain commands (like downloading / plotting) # Allow no-config for certain commands (like downloading / plotting)
if (parsed_arg.config is None if (parsed_arg.config is None and ((Path.cwd() / constants.DEFAULT_CONFIG).is_file() or
and not ('subparser' in parsed_arg and parsed_arg.subparser in NO_CONF_REQURIED)): not ('subparser' in parsed_arg and parsed_arg.subparser in NO_CONF_REQURIED))):
parsed_arg.config = [constants.DEFAULT_CONFIG] parsed_arg.config = [constants.DEFAULT_CONFIG]
return parsed_arg return parsed_arg

View File

@ -871,6 +871,8 @@ def test_pairlist_resolving_fallback(mocker):
] ]
args = Arguments(arglist).get_parsed_arg() args = Arguments(arglist).get_parsed_arg()
# Fix flaky tests if config.json exists
args.config = None
configuration = Configuration(args) configuration = Configuration(args)
config = configuration.get_config() config = configuration.get_config()