Rename methods to make exposure explicit
This commit is contained in:
@@ -9,7 +9,7 @@ from freqtrade.misc import deep_merge_dicts
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_var_typed(val):
|
def _get_var_typed(val):
|
||||||
try:
|
try:
|
||||||
return int(val)
|
return int(val)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@@ -24,7 +24,7 @@ def get_var_typed(val):
|
|||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
def flat_vars_to_nested_dict(env_dict: Dict[str, Any], prefix: str) -> Dict[str, Any]:
|
def _flat_vars_to_nested_dict(env_dict: Dict[str, Any], prefix: str) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Environment variables must be prefixed with FREQTRADE.
|
Environment variables must be prefixed with FREQTRADE.
|
||||||
FREQTRADE__{section}__{key}
|
FREQTRADE__{section}__{key}
|
||||||
@@ -40,7 +40,7 @@ def flat_vars_to_nested_dict(env_dict: Dict[str, Any], prefix: str) -> Dict[str,
|
|||||||
logger.info(f"Loading variable '{env_var}'")
|
logger.info(f"Loading variable '{env_var}'")
|
||||||
key = env_var.replace(prefix, '')
|
key = env_var.replace(prefix, '')
|
||||||
for k in reversed(key.split('__')):
|
for k in reversed(key.split('__')):
|
||||||
val = {k.lower(): get_var_typed(val)
|
val = {k.lower(): _get_var_typed(val)
|
||||||
if not isinstance(val, dict) and k not in no_convert else val}
|
if not isinstance(val, dict) and k not in no_convert else val}
|
||||||
relevant_vars = deep_merge_dicts(val, relevant_vars)
|
relevant_vars = deep_merge_dicts(val, relevant_vars)
|
||||||
return relevant_vars
|
return relevant_vars
|
||||||
@@ -52,4 +52,4 @@ def enironment_vars_to_dict() -> Dict[str, Any]:
|
|||||||
Relevant variables must follow the FREQTRADE__{section}__{key} pattern
|
Relevant variables must follow the FREQTRADE__{section}__{key} pattern
|
||||||
:return: Nested dict based on available and relevant variables.
|
:return: Nested dict based on available and relevant variables.
|
||||||
"""
|
"""
|
||||||
return flat_vars_to_nested_dict(os.environ.copy(), ENV_VAR_PREFIX)
|
return _flat_vars_to_nested_dict(os.environ.copy(), ENV_VAR_PREFIX)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from freqtrade.configuration.deprecated_settings import (check_conflicting_setti
|
|||||||
process_deprecated_setting,
|
process_deprecated_setting,
|
||||||
process_removed_setting,
|
process_removed_setting,
|
||||||
process_temporary_deprecated_settings)
|
process_temporary_deprecated_settings)
|
||||||
from freqtrade.configuration.environment_vars import flat_vars_to_nested_dict
|
from freqtrade.configuration.environment_vars import _flat_vars_to_nested_dict
|
||||||
from freqtrade.configuration.load_config import (load_config_file, load_file, load_from_files,
|
from freqtrade.configuration.load_config import (load_config_file, load_file, load_from_files,
|
||||||
log_config_error_range)
|
log_config_error_range)
|
||||||
from freqtrade.constants import DEFAULT_DB_DRYRUN_URL, DEFAULT_DB_PROD_URL, ENV_VAR_PREFIX
|
from freqtrade.constants import DEFAULT_DB_DRYRUN_URL, DEFAULT_DB_PROD_URL, ENV_VAR_PREFIX
|
||||||
@@ -1419,7 +1419,7 @@ def test_flat_vars_to_nested_dict(caplog):
|
|||||||
'chat_id': '2151'
|
'chat_id': '2151'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = flat_vars_to_nested_dict(test_args, ENV_VAR_PREFIX)
|
res = _flat_vars_to_nested_dict(test_args, ENV_VAR_PREFIX)
|
||||||
assert res == expected
|
assert res == expected
|
||||||
|
|
||||||
assert log_has("Loading variable 'FREQTRADE__EXCHANGE__SOME_SETTING'", caplog)
|
assert log_has("Loading variable 'FREQTRADE__EXCHANGE__SOME_SETTING'", caplog)
|
||||||
|
|||||||
Reference in New Issue
Block a user