Repository navigation
Review: return false when dotenv contains only valueless declarations - #1
srijan2607 wants to merge 1 commit into
Conversation
Implemented and tested with AI assistance; independently reviewed by a separate AI agent. Pending Srijan's human review; not submitted upstream.
Preview only; not submitted upstream.Approval requested for head Exact proposed upstream titleReturn false when dotenv contains only valueless declarations Exact proposed upstream body
Return Tests cover file and stream inputs, both override modes, existing environment values, bare-only content, empty assignments and mixed content. Testing on Python 3.13:
Code, tests and this description were prepared with AI assistance and reviewed by a separate AI agent. Personal human review and the other Python/OS combinations are not claimed by this draft. Prerequisite issue textNone proposed: the inspected contribution instructions welcome an issue or a pull request and do not require an issue first. This is an original bounded discovery, not a claim that an existing issue is assigned or resolved. No issue has been opened. Commit identity was corrected without changing any file tree; original execution logs retain their original source hashes as provenance. The current approval target is the metadata-equivalent head above. |
Captured regression evidence and independent agent reviewThis evidence belongs to head Exact-base failing control (output excerpt)The final regression tests were copied to a pristine base worktree; expected exit status: 1. Patched complete-suite rerun (captured output)Independent adversarial reviewVerdict: APPROVE_FOR_FORK_REVIEW, bound to complete patch SHA-256 The reviewer separately ran the 22 regressions, full suite, lint/format and exact-base negative control. A differential probe exercised 4,680 cases and observed only the intended return-value differences for all-None mappings; parsed mappings and final environments matched the original implementation. Existing no-override success behavior was preserved. Historical return-value discussions were checked separately from unrelated parent-directory searching. Limits: bounded local execution only; no upstream CI or additional OS/Python matrix is represented as completed. Personal human review and approval of the separate exact upstream-text preview are still pending. Commit identity was corrected without changing any file tree; original execution logs retain their original source hashes as provenance. The current approval target is the metadata-equivalent head above. |
beb9e9b to
0f7609f
Compare
|
Superseded by #2. The replacement draft targets this fork’s main and retains the same corrected code head |
Commit-attribution correction: author and committer now link to https://github.com/srijan2607. This is a metadata-only history rewrite; every file tree is identical to the tested version. Recorded local test results remain evidence for the same code; CI must be checked at the new head.
Problem and scope
load_dotenv(stream=StringIO("EXAMPLE_KEY"))returnsTrueeven though a bare declaration has no value and is ignored. This patch returnsFalsewhen every parsed declaration has valueNone, matching the existing empty-configuration result. Empty-string assignments still count as values.Only
src/dotenv/main.pyand the newtests/test_load_result.pychange. The implementation predicate matches the existingif v is not Noneassignment guard. Parsing, interpolation, environment contents, file discovery and override behavior are unchanged. In particular, an ordinary valued assignment skipped becauseoverride=Falsestill returnsTrue; this is not a general redesign of the return contract.Review boundary
This is a public draft in my own fork, not an upstream submission. Code, tests and this description were prepared with AI assistance. A separate AI agent performed adversarial review; that is not human review. My personal review and explicit approval of both this head and the separate upstream-text preview remain pending. Do not merge or submit upstream from this draft.
0b2880591780a426b0551436f47a17e7a76d954f0f7609f116b19ac7355daa6b5d9147a8c5817907Noneversus empty-string boundary, existing-ambient-variable behavior, and file/stream regression cases.Portable clean-checkout setup and checks
Requires Git, uv and Python 3.13. These dependency versions match the executed local checks; this is a focused test environment, not the complete optional development-tool installation.
Expected targeted result: 22 passed. Full suite observed: 306 passed, 1 skipped (IPython unavailable), with existing Click deprecation warnings. If an ancestor directory contains an unrelated
.env, file-discovery tests can pick it up; use an isolated fresh checkout/test directory without an ancestor.env.Minimal visible behavior:
.venv/bin/python -c 'from io import StringIO; from dotenv import load_dotenv; print(load_dotenv(stream=StringIO("EXAMPLE_KEY"))); print(load_dotenv(stream=StringIO("EXAMPLE_KEY=")))'Expected after:
False, thenTrue. Before:True, thenTrue.Causal before-control with the same regression tests
Run from the patched checkout after setup:
git worktree add --detach ../python-dotenv-before 0b2880591780a426b0551436f47a17e7a76d954f cp tests/test_load_result.py ../python-dotenv-before/tests/test_load_result.py PYTHONPATH="$PWD/../python-dotenv-before/src" .venv/bin/python -m pytest ../python-dotenv-before/tests/test_load_result.py -q --basetemp .before-test-tmpExpected nonzero exit: 16 failed, 6 passed, with false-return assertions failing on the original implementation. Do not treat that expected negative control as a setup failure.
Actual verification and limits
dotenvconsole script. An earlier reviewer run used a temporary launcher for the same CLI because that environment initially lacked the script; it is not an installation test. One later setup attempt lacked the requested temporary parent directory; it was corrected before the successful rerun. A default temporary-directory run encountered the unrelated ancestor-.envfixture interference described above.Captured failing/passing output is provided in a separate evidence comment. Proposed upstream title/body are in another separate comment and require approval before submission.