Simplify return valuef rom _load_object

This commit is contained in:
Matthias 2019-07-21 15:25:48 +02:00
parent 88eb93da52
commit 08ca260e82
4 changed files with 11 additions and 19 deletions

View File

@ -63,10 +63,8 @@ class HyperOptResolver(IResolver):
# Add extra hyperopt directory on top of search paths # Add extra hyperopt directory on top of search paths
abs_paths.insert(0, Path(extra_dir)) abs_paths.insert(0, Path(extra_dir))
(hyperopt, module_path) = self._load_object(paths=abs_paths, hyperopt = self._load_object(paths=abs_paths, object_type=IHyperOpt,
object_type=IHyperOpt, object_name=hyperopt_name)
object_name=hyperopt_name,
kwargs={})
if hyperopt: if hyperopt:
return hyperopt return hyperopt
raise OperationalException( raise OperationalException(
@ -120,10 +118,8 @@ class HyperOptLossResolver(IResolver):
# Add extra hyperopt directory on top of search paths # Add extra hyperopt directory on top of search paths
abs_paths.insert(0, Path(extra_dir)) abs_paths.insert(0, Path(extra_dir))
(hyperoptloss, module_path) = self._load_object(paths=abs_paths, hyperoptloss = self._load_object(paths=abs_paths, object_type=IHyperOptLoss,
object_type=IHyperOptLoss, object_name=hyper_loss_name)
object_name=hyper_loss_name,
kwargs={})
if hyperoptloss: if hyperoptloss:
return hyperoptloss return hyperoptloss

View File

@ -67,7 +67,7 @@ class IResolver(object):
@staticmethod @staticmethod
def _load_object(paths: List[Path], object_type, object_name: str, def _load_object(paths: List[Path], object_type, object_name: str,
kwargs: dict = {}) -> Union[Tuple[Any, Path], Tuple[None, None]]: kwargs: dict = {}) -> Union[Any, None]:
""" """
Try to load object from path list. Try to load object from path list.
""" """
@ -82,8 +82,8 @@ class IResolver(object):
logger.info( logger.info(
f"Using resolved {object_type.__name__.lower()[1:]} {object_name} " f"Using resolved {object_type.__name__.lower()[1:]} {object_name} "
f"from '{module_path}'...") f"from '{module_path}'...")
return (module, module_path) return module
except FileNotFoundError: except FileNotFoundError:
logger.warning('Path "%s" does not exist.', _path.relative_to(Path.cwd())) logger.warning('Path "%s" does not exist.', _path.relative_to(Path.cwd()))
return (None, None) return None

View File

@ -43,10 +43,8 @@ class PairListResolver(IResolver):
current_path, current_path,
] ]
(pairlist, module_path) = self._load_object(paths=abs_paths, pairlist = self._load_object(paths=abs_paths, object_type=IPairList,
object_type=IPairList, object_name=pairlist_name, kwargs=kwargs)
object_name=pairlist_name,
kwargs=kwargs)
if pairlist: if pairlist:
return pairlist return pairlist
raise OperationalException( raise OperationalException(

View File

@ -147,10 +147,8 @@ class StrategyResolver(IResolver):
# register temp path with the bot # register temp path with the bot
abs_paths.insert(0, temp.resolve()) abs_paths.insert(0, temp.resolve())
(strategy, module_path) = self._load_object(paths=abs_paths, strategy = self._load_object(paths=abs_paths, object_type=IStrategy,
object_type=IStrategy, object_name=strategy_name, kwargs={'config': config})
object_name=strategy_name,
kwargs={'config': config})
if strategy: if strategy:
strategy._populate_fun_len = len(getfullargspec(strategy.populate_indicators).args) strategy._populate_fun_len = len(getfullargspec(strategy.populate_indicators).args)
strategy._buy_fun_len = len(getfullargspec(strategy.populate_buy_trend).args) strategy._buy_fun_len = len(getfullargspec(strategy.populate_buy_trend).args)