|
21 | 21 | logger = logging.getLogger(__name__)
|
22 | 22 |
|
23 | 23 |
|
| 24 | +def _load_dotenv_disabled() -> bool: |
| 25 | + """ |
| 26 | + Determine if dotenv loading has been disabled. |
| 27 | + """ |
| 28 | + if "PYTHON_DOTENV_DISABLED" not in os.environ: |
| 29 | + return False |
| 30 | + value = os.environ["PYTHON_DOTENV_DISABLED"].casefold() |
| 31 | + return value in {"1", "true", "t", "yes", "y"} |
| 32 | + |
| 33 | + |
24 | 34 | def with_warn_for_invalid_lines(mappings: Iterator[Binding]) -> Iterator[Binding]:
|
25 | 35 | for mapping in mappings:
|
26 | 36 | if mapping.error:
|
@@ -349,11 +359,14 @@ def load_dotenv(
|
349 | 359 | .env file with it's default parameters. If you need to change the default parameters
|
350 | 360 | of `find_dotenv()`, you can explicitly call `find_dotenv()` and pass the result
|
351 | 361 | to this function as `dotenv_path`.
|
| 362 | +
|
| 363 | + If the environment variable `PYTHON_DOTENV_DISABLED` is set to a truthy value, |
| 364 | + .env loading is disabled. |
352 | 365 | """
|
353 | 366 | if _load_dotenv_disabled():
|
354 | 367 | logger.debug(
|
355 |
| - "python-dotenv: .env loading disabled by PYTHON_DOTENV_DISABLED environment variable" |
356 |
| - ) |
| 368 | + "python-dotenv: .env loading disabled by PYTHON_DOTENV_DISABLED environment variable" |
| 369 | + ) |
357 | 370 | return False
|
358 | 371 |
|
359 | 372 | if dotenv_path is None and stream is None:
|
@@ -404,12 +417,3 @@ def dotenv_values(
|
404 | 417 | override=True,
|
405 | 418 | encoding=encoding,
|
406 | 419 | ).dict()
|
407 |
| - |
408 |
| -def _load_dotenv_disabled() -> bool: |
409 |
| - """ |
410 |
| - Determine if dotenv loading has been disabled. |
411 |
| - """ |
412 |
| - if "PYTHON_DOTENV_DISABLED" not in os.environ: |
413 |
| - return False |
414 |
| - value = os.environ["PYTHON_DOTENV_DISABLED"].casefold() |
415 |
| - return value in {"1", "true", "t", "yes", "y"} |
|
0 commit comments