linter fixes and cleanups

This commit is contained in:
Janne Sinivirta 2018-01-09 13:06:28 +02:00
parent 1b6b0ad9d2
commit 0abc30401c
3 changed files with 13 additions and 14 deletions

View File

@ -57,8 +57,8 @@ def load_config(path: str) -> Dict:
try:
validate(conf, CONF_SCHEMA)
return conf
except ValidationError as ex:
logger.fatal('Invalid configuration. See config.json.example. Reason: %s', ex)
except ValidationError as exception:
logger.fatal('Invalid configuration. See config.json.example. Reason: %s', exception)
raise ValidationError(
best_match(Draft4Validator(CONF_SCHEMA).iter_errors(conf)).message
)
@ -81,7 +81,7 @@ def throttle(func: Callable[..., Any], min_secs: float, *args, **kwargs) -> Any:
return result
def parse_args_common(args: List[str], description: str):
def common_args_parser(description: str):
"""
Parses given common arguments and returns them as a parsed object.
"""
@ -117,11 +117,11 @@ def parse_args(args: List[str], description: str):
Parses given arguments and returns an argparse Namespace instance.
Returns None if a sub command has been selected and executed.
"""
parser = parse_args_common(args, description)
parser = common_args_parser(description)
parser.add_argument(
'--dry-run-db',
help='Force dry run to use a local DB "tradesv3.dry_run.sqlite" instead of memory DB. Work only if dry_run is \
enabled.', # noqa
help='Force dry run to use a local DB "tradesv3.dry_run.sqlite" \
instead of memory DB. Work only if dry_run is enabled.',
action='store_true',
dest='dry_run_db',
)
@ -135,7 +135,8 @@ def parse_args(args: List[str], description: str):
)
parser.add_argument(
'--dynamic-whitelist',
help='dynamically generate and update whitelist based on 24h BaseVolume (Default 20 currencies)', # noqa
help='dynamically generate and update whitelist \
based on 24h BaseVolume (Default 20 currencies)', # noqa
dest='dynamic_whitelist',
const=20,
type=int,

View File

@ -8,7 +8,7 @@ import pytest
from jsonschema import ValidationError
from freqtrade.misc import throttle, parse_args, load_config,\
parse_args_common
common_args_parser
def test_throttle():
@ -39,12 +39,10 @@ def test_throttle_with_assets():
assert result == -1
# Parse common command-line-arguments
# used for all tools
# Parse common command-line-arguments. Used for all tools
def test_parse_args_none():
args = parse_args_common([], '')
args = common_args_parser('')
assert isinstance(args, argparse.ArgumentParser)

View File

@ -6,11 +6,11 @@ import matplotlib # Install PYQT5 manually if you want to test this helper func
matplotlib.use("Qt5Agg")
import matplotlib.pyplot as plt
from freqtrade import exchange, analyze
from freqtrade.misc import parse_args_common
from freqtrade.misc import common_args_parser
def plot_parse_args(args ):
parser = parse_args_common(args, 'Graph utility')
parser = common_args_parser(args, 'Graph utility')
parser.add_argument(
'-p', '--pair',
help = 'What currency pair',