HBNetwork / python-decouple

Strict separation of config from code.
MIT License
2.82k stars 195 forks source link

Feature Request: Fallback to .env.example #147

Closed aqeelat closed 1 year ago

aqeelat commented 1 year ago

Hi,

Thank you so much for this great package.

Would it be possible to do a fallback on .env.example when the value is not in .env?

Currently, in our github action, we have to rename .env.example to .env in order to run the tests. Also, when someone adds a value to .env.example that I don't really need, I should still be able to run the application. This will allow .env to be shorter and contains only the values that I need to change.

b0o commented 1 year ago

Does my comment here help? https://github.com/HBNetwork/python-decouple/issues/142#issuecomment-1426977504

henriquebastos commented 1 year ago

@aqeelat try this:

from collections import ChainMap
from decouple import Config, RepositoryEnv

config = Config(ChainMap(RepositoryEnv(".private.env"), RepositoryEnv(".env")))
shayneoneill commented 1 year ago

Not a fan of this idea. Preferably you'd want an unconfigured app to fail, because thats a big red flag saying "Hey this thing can bite you, please make sure your not about to blow up your company, and check the config first!".