thesimj / envyaml

Simple YAML configuration file parser
MIT License
78 stars 21 forks source link

Handling of unset/empty environment variables #3

Closed moreinhardt closed 3 years ago

moreinhardt commented 3 years ago

Is the following intended?

foo: "xx${BAR}zzz"

When BAR isn't set, in the shell this would evaluate to "xxzzz". When I use this package I get the following:

from envyaml import EnvYAML
env = EnvYAML()
env["foo"] is None  # True

I think the default behaviour should be to perform the expansion like the shell does.

And I propose a flag that can be passed to __init__() to raise errors in case of unset (and empty?) variables that should be parsed. e.g. env = EnvYAML(ignore_unset=False) -> would raise an error (default True of course).

What do you think? I'd be happy to contribute this.

thesimj commented 3 years ago

this feature will be addressed in version 1.0.0 (branch https://github.com/thesimj/envyaml/tree/develop-v1)

thesimj commented 3 years ago

Stable version v1 with strict mode and default values. I will be appreciate if you could review it.

https://github.com/thesimj/envyaml/tree/develop-v1