loganasherjones / yapconf

Yet Another Python Configuration
http://yapconf.readthedocs.io/en/stable/
MIT License
18 stars 4 forks source link

Environment loading with a label #88

Open hazmat345 opened 6 years ago

hazmat345 commented 6 years ago

Trying to load configuration using the ENVIRONMENT source as shown in the README.

Given this spec:

spec = YapconfSpec({
    "foo": {"type": "str"},
}, env_prefix="MY_APP_")

This seems to work as expected:

spec.load_config('ENVIRONMENT')

But this does not (and this is basically what's currently in the readme):

spec.add_source('environment', 'environment')
spec.load_config('environment')

The latter seems to sort of load from the environment - if there's an environment variable foo that will be used. As in, the env_prefix and snake-casification (although it doesn't apply in this case) aren't getting applied.

However, this does seem to work:

my_spec.add_source('ENVIRONMENT', 'environment')
my_spec.load_config('ENVIRONMENT')

Although I'm not sure if the first line actually has any effect as this may be getting interpreted as the first example.

I believe the tests for loading from the environment all use the upper-case version. I will add a test to see if I can get a failure based on this issue.