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
from typing import List, Optional
from pathlib import Path
from freqtrade.configuration.cli_options import AVAILABLE_CLI_OPTIONS
from freqtrade import constants
@ -73,11 +74,13 @@ class Arguments(object):
"""
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
# (see https://bugs.python.org/issue16399)
# Allow no-config for certain commands (like downloading / plotting)
if (parsed_arg.config is None
and not ('subparser' in parsed_arg and parsed_arg.subparser in NO_CONF_REQURIED)):
if (parsed_arg.config is None and ((Path.cwd() / constants.DEFAULT_CONFIG).is_file() or
not ('subparser' in parsed_arg and parsed_arg.subparser in NO_CONF_REQURIED))):
parsed_arg.config = [constants.DEFAULT_CONFIG]
return parsed_arg

View File

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