Skip to content

Return false when dotenv contains only valueless declarations - #733

Open
srijan2607 wants to merge 1 commit into
theskumar:mainfrom
srijan2607:fix/valueless-load-result-reissued
Open

srijan2607 wants to merge 1 commit into
theskumar:mainfrom
srijan2607:fix/valueless-load-result-reissued

Conversation

@srijan2607

Copy link
Copy Markdown

load_dotenv() returns True for content containing only bare declarations such as EXAMPLE_KEY, although those declarations are ignored and cannot set environment variables.

Return False when all parsed values are None, matching the existing empty-configuration result. Empty-string assignments remain valid, and valued assignments skipped by override=False retain their existing result. Parsing, interpolation and environment contents are unchanged.

Add 22 regression cases covering file/stream inputs, both override modes, existing environment values, bare-only declarations, empty assignments and mixed content.

Testing on Python 3.13.13:

  • Original implementation with the new tests: 16 failed, 6 passed (expected negative control).
  • Patched regression tests: 22 passed.
  • Full suite: 306 passed, 1 skipped (optional IPython unavailable).
  • Ruff lint/format checks and git diff --check passed.

Kept as a draft pending CI verification; local results are not a CI pass. Windows and other Python versions have not been tested locally.

Implemented and tested with AI assistance; independently reviewed by a separate AI agent. Pending Srijan's human review; not submitted upstream.
@srijan2607

Copy link
Copy Markdown
Author

All nine CI test jobs are passing. Could this be reviewed when convenient?

This branch has not been deployed

No deployments
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