pyaml_env
pyaml_env copied to clipboard
Add option for raising an error on missing ENV variable
This PR implements #22 by adding a raise_if_missing option to the parse_config function.
If raise_if_missing is set to True, a ValueError is raised when the following conditions are met:
- The ENV variable is not set
- No default is set for the ENV variable
Example:
# ValueError is raised
data: !ENV ${NON_EXISTING_ENV}
# No ValueError is raised
data: !ENV ${NON_EXISTING_ENV:explicit_default_value}
For backwards compatibility, raise_if_missing is set to False by default.
+1. If anything, should be the default behavior of raise_if_na. Sometimes you just don't have a default value.
+1, very useful!
@mkaranasou - can we get this merged, once you have a spare moment?