Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c56f00d

Browse filesBrowse files
committed
Add override-flag to dotenv_values to allow for more advanced chaining
1 parent 1ea25f3 commit c56f00d
Copy full SHA for c56f00d

File tree

3 files changed

+8
-2
lines changed
Filter options

3 files changed

+8
-2
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+2
Original file line numberDiff line numberDiff 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

‎README.md

Copy file name to clipboardExpand all lines: README.md
+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ deploy_env = {
110110
'VERSION': '1.5',
111111
}
112112
env = 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
})
116117
subprocess.call(

‎src/dotenv/main.py

Copy file name to clipboardExpand all lines: src/dotenv/main.py
+4-1
Original file line numberDiff line numberDiff 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()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.