File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1111
1212- Add support to use a custom dict instead of os.environ for variable
1313 interpolating when calling ` dotenv_values ` (by [ @johnbergvall ] )
14+ - Add override-flag to ` dotenv_values ` to allow for more advanced
15+ chaining of env-files (#73 #186 by [ @johnbergvall ] )
1416
1517## [ 0.19.0] - 2021-07-24
1618
Original file line number Diff line number Diff line change @@ -110,7 +110,8 @@ deploy_env = {
110110 ' VERSION' : ' 1.5' ,
111111}
112112env = dotenv_values(' .env.deployment01' , base_env = {
113- ** dotenv_values(' .env.base' , base_env = deploy_env),
113+ # override=False to ignore local file overrides in interpolations:
114+ ** dotenv_values(' .env.base' , override = False , base_env = deploy_env),
114115 ** deploy_env,
115116})
116117subprocess.call(
Original file line number Diff line number Diff line change @@ -337,6 +337,7 @@ def dotenv_values(
337337 dotenv_path : Union [str , _PathLike , None ] = None ,
338338 stream : Optional [IO [str ]] = None ,
339339 verbose : bool = False ,
340+ override : bool = True ,
340341 interpolate : bool = True ,
341342 encoding : Optional [str ] = "utf-8" ,
342343 base_env : Mapping [str , Optional [str ]] = os .environ ,
@@ -348,6 +349,8 @@ def dotenv_values(
348349 - *stream*: `StringIO` object with .env content, used if `dotenv_path` is `None`.
349350 - *verbose*: whether to output a warning the .env file is missing. Defaults to
350351 `False`.
352+ - *override*: whether to override the system environment/`base_env` variables with
353+ the variables in `.env` file. Defaults to `True` as opposed to `load_dotenv`.
351354 - *encoding*: encoding to be used to read the file.
352355 - *base_env*: dict with initial environment. Defaults to os.environ
353356
@@ -361,7 +364,7 @@ def dotenv_values(
361364 stream = stream ,
362365 verbose = verbose ,
363366 interpolate = interpolate ,
364- override = True ,
367+ override = override ,
365368 encoding = encoding ,
366369 base_env = base_env ,
367370 ).dict ()
You can’t perform that action at this time.
0 commit comments