Increase pylint score on misc.py

This commit is contained in:
Gerald Lonlas 2018-01-28 14:28:28 -08:00
parent 45a34be2ac
commit 2bccaa31c9
2 changed files with 15 additions and 16 deletions

View File

@ -60,7 +60,7 @@ def common_datearray(dfs):
return np.sort(arr, axis=0) return np.sort(arr, axis=0)
def file_dump_json(filename, data): def file_dump_json(filename, data) -> None:
with open(filename, 'w') as fp: with open(filename, 'w') as fp:
json.dump(data, fp) json.dump(data, fp)
@ -287,27 +287,27 @@ def hyperopt_options(parser: argparse.ArgumentParser) -> None:
def parse_timerange(text): def parse_timerange(text):
if text is None: if text is None:
return None return None
syntax = [('^-(\d{8})$', (None, 'date')), syntax = [(r'^-(\d{8})$', (None, 'date')),
('^(\d{8})-$', ('date', None)), (r'^(\d{8})-$', ('date', None)),
('^(\d{8})-(\d{8})$', ('date', 'date')), (r'^(\d{8})-(\d{8})$', ('date', 'date')),
('^(-\d+)$', (None, 'line')), (r'^(-\d+)$', (None, 'line')),
('^(\d+)-$', ('line', None)), (r'^(\d+)-$', ('line', None)),
('^(\d+)-(\d+)$', ('index', 'index'))] (r'^(\d+)-(\d+)$', ('index', 'index'))]
for rex, stype in syntax: for rex, stype in syntax:
# Apply the regular expression to text # Apply the regular expression to text
m = re.match(rex, text) match = re.match(rex, text)
if m: # Regex has matched if match: # Regex has matched
rvals = m.groups() rvals = match.groups()
n = 0 index = 0
start = None start = None
stop = None stop = None
if stype[0]: if stype[0]:
start = rvals[n] start = rvals[index]
if stype[0] != 'date': if stype[0] != 'date':
start = int(start) start = int(start)
n += 1 index += 1
if stype[1]: if stype[1]:
stop = rvals[n] stop = rvals[index]
if stype[1] != 'date': if stype[1] != 'date':
stop = int(stop) stop = int(stop)
return (stype, start, stop) return (stype, start, stop)

View File

@ -26,8 +26,7 @@ def trim_tickerlist(tickerlist, timerange):
return tickerlist return tickerlist
def load_tickerdata_file(datadir, pair, ticker_interval, def load_tickerdata_file(datadir, pair, ticker_interval, timerange=None):
timerange=None):
""" """
Load a pair from file, Load a pair from file,
:return dict OR empty if unsuccesful :return dict OR empty if unsuccesful