Skip to content

Fix load_dotenv return value when no variables are set - #760

Closed
adityajai119 wants to merge 1 commit into
theskumar:mainfrom
adityajai119:fix-load-dotenv-bare-keys
Closed

adityajai119 wants to merge 1 commit into
theskumar:mainfrom
adityajai119:fix-load-dotenv-bare-keys

Conversation

@adityajai119

Copy link
Copy Markdown

load_dotenv() documents returning True "if at least one environment variable is set", but DotEnv.set_as_environment_variables() returned True whenever the parsed dict was non-empty. A .env containing only bare keys (e.g. FOO) therefore reported True while setting nothing.

This changes the return value to reflect whether a variable was actually written.

Test: test_load_dotenv_only_bare_keys fails before the fix (assert True is False) and passes after it. PYTHONPATH=src python -m pytest tests/test_main.py -q -> 110 passed, 47 skipped. ruff check and ruff format --check pass on both changed files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant