Skip to content

Commit 2235ff4

Browse files
Change environmental variable to PYTHON_DOTENV_DISABLED
1 parent c0d4772 commit 2235ff4

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Optional flags:
136136

137137
### Disable load_dotenv
138138

139-
You can disable automatic loading of dotenv values by setting the `DOTENV_AUTOLOAD_DISABLED` environmental variable to `true`. This can be useful if you are using a library that uses `load_dotenv` and you want to manage the environment in a different way.
139+
You can disable automatic loading of dotenv values by setting the `PYTHON_DOTENV_DISABLED` environmental variable to `true`. This can be useful if you are using a library that uses `load_dotenv` and you want to manage the environment in a different way.
140140

141141
## Command-line Interface
142142

src/dotenv/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,9 @@ def load_dotenv(
350350
of `find_dotenv()`, you can explicitly call `find_dotenv()` and pass the result
351351
to this function as `dotenv_path`.
352352
"""
353-
if _dotenv_autoload_disabled():
353+
if _load_dotenv_disabled():
354354
logger.warning(
355-
"python-dotenv has been disabled by DOTENV_AUTOLOAD_DISABLED environmental variable"
355+
"python-dotenv has been disabled by PYTHON_DOTENV_DISABLED environmental variable"
356356
)
357357
return False
358358

@@ -405,11 +405,11 @@ def dotenv_values(
405405
encoding=encoding,
406406
).dict()
407407

408-
def _dotenv_autoload_disabled() -> bool:
408+
def _load_dotenv_disabled() -> bool:
409409
"""
410-
Determine if dotenv autoloading has been disabled.
410+
Determine if dotenv loading has been disabled.
411411
"""
412-
if "DOTENV_AUTOLOAD_DISABLED" not in os.environ:
412+
if "PYTHON_DOTENV_DISABLED" not in os.environ:
413413
return False
414-
value = os.environ["DOTENV_AUTOLOAD_DISABLED"].casefold()
414+
value = os.environ["PYTHON_DOTENV_DISABLED"].casefold()
415415
return value in {"1", "true", "t", "yes", "y"}

tests/test_main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ def test_load_dotenv_existing_file(dotenv_path):
262262
],
263263
)
264264
def test_load_dotenv_disabled(dotenv_path, flag_value):
265-
expected_environ = {"DOTENV_AUTOLOAD_DISABLED": flag_value}
266-
with mock.patch.dict(os.environ, {"DOTENV_AUTOLOAD_DISABLED": flag_value}, clear=True):
265+
expected_environ = {"PYTHON_DOTENV_DISABLED": flag_value}
266+
with mock.patch.dict(os.environ, {"PYTHON_DOTENV_DISABLED": flag_value}, clear=True):
267267
dotenv_path.write_text("a=b")
268268

269269
result = dotenv.load_dotenv(dotenv_path)
@@ -290,8 +290,8 @@ def test_load_dotenv_disabled(dotenv_path, flag_value):
290290
],
291291
)
292292
def test_load_dotenv_enabled(dotenv_path, flag_value):
293-
expected_environ = {"DOTENV_AUTOLOAD_DISABLED": flag_value, "a": "b"}
294-
with mock.patch.dict(os.environ, {"DOTENV_AUTOLOAD_DISABLED": flag_value}, clear=True):
293+
expected_environ = {"PYTHON_DOTENV_DISABLED": flag_value, "a": "b"}
294+
with mock.patch.dict(os.environ, {"PYTHON_DOTENV_DISABLED": flag_value}, clear=True):
295295
dotenv_path.write_text("a=b")
296296

297297
result = dotenv.load_dotenv(dotenv_path)
@@ -302,12 +302,12 @@ def test_load_dotenv_enabled(dotenv_path, flag_value):
302302

303303
@mock.patch.dict(os.environ, {}, clear=True)
304304
def test_load_dotenv_doesnt_disable_itself(dotenv_path):
305-
dotenv_path.write_text("DOTENV_AUTOLOAD_DISABLED=true")
305+
dotenv_path.write_text("PYTHON_DOTENV_DISABLED=true")
306306

307307
result = dotenv.load_dotenv(dotenv_path)
308308

309309
assert result is True
310-
assert os.environ == {"DOTENV_AUTOLOAD_DISABLED": "true"}
310+
assert os.environ == {"PYTHON_DOTENV_DISABLED": "true"}
311311

312312

313313
def test_load_dotenv_no_file_verbose():

0 commit comments

Comments
 (0)