Closed shaybensasson closed 3 years ago
Notice the following .env snippet from the popular python-dotenv package:
.env
DOMAIN=example.org ADMIN_EMAIL=admin@${DOMAIN} ADMIN_PASSWORD=super_secret_password ROOT_URL=${DOMAIN}/app
If we load this .env using the current envyaml we'll get:
envyaml
dict( DOMAIN="example.org", ADMIN_EMAIL="admin@${DOMAIN}", ADMIN_PASSWORD="super_secret_password", ROOT_URL="${DOMAIN}/app" )
I suggest fixing this by adding a kwargs as I did on the EnvYAML.__init__ ctor.
kwargs
EnvYAML.__init__
This will allow the following code:
def envyaml_with_dotenv_demo(): from envyaml import EnvYAML dotenv_path = Path('.') / '.env' # read file env.yaml and parse config env_yaml_path = Path('.') / 'env.yaml' env = EnvYAML(env_yaml_path, env_file=dotenv_path, # don't fail if some env var is missing strict=False, **dotenv.dotenv_values(dotenv_path) )
I also added a dedicated test: test_it_should_override_cfg_with_kwargs.
test_it_should_override_cfg_with_kwargs
I just noticed I forgot to update the setup.py::install_requires with python-dotenv.
setup.py
install_requires
python-dotenv
thanks, for your PR
Notice the following
.env
snippet from the popular python-dotenv package:If we load this
.env
using the currentenvyaml
we'll get:I suggest fixing this by adding a
kwargs
as I did on theEnvYAML.__init__
ctor.This will allow the following code:
I also added a dedicated test:
test_it_should_override_cfg_with_kwargs
.I just noticed I forgot to update the
setup.py
::install_requires
withpython-dotenv
.