dynaconf icon indicating copy to clipboard operation
dynaconf copied to clipboard

[bug] Default environment always loaded, also when var is already defined

Open jorritsmit opened this issue 3 years ago • 2 comments

Describe the bug As i understand from reading the code, the default environment is implemented by adding it to the environment list in build_env_list(). This means, however, that if a change my environment (in my case using from_env) the default settings overwrite the existing settings (again as i understand). This seems like undesirable behavior to me, as i expect default settings to only be set when they are not defined already.

To Reproduce Steps to reproduce the behavior: use below config files and perform: from config.config import settings as base_cfg cfg = base_cfg.from_env(env2, keep=True).from_env(env1, keep=True) print(cfg.TEST) desired result should be False, but is True

  1. Having the following config files:
Config files

/path/settings.toml

[default]
TEST = true
[env1]

[env2]
TEST = false

jorritsmit avatar Mar 20 '21 19:03 jorritsmit

I think this is related to https://github.com/rochacbruno/dynaconf/issues/344

rochacbruno avatar Mar 21 '21 00:03 rochacbruno

I think this is related to #344

It is a duplicate indeed I think. My apologies

jorritsmit avatar Mar 21 '21 00:03 jorritsmit