Skip to content

Resolve absolute dotenv paths without discovering a search directory - #726

Open
FanWu-ai wants to merge 1 commit into
theskumar:mainfrom
FanWu-ai:fix-absolute-dotenv-discovery-20261008
Open

FanWu-ai wants to merge 1 commit into
theskumar:mainfrom
FanWu-ai:fix-absolute-dotenv-discovery-20261008

Conversation

@FanWu-ai

@FanWu-ai FanWu-ai commented Oct 8, 2026

Copy link
Copy Markdown

find_dotenv() documents that an absolute filename is returned as-is, but first tries to discover a search directory. If the working directory has been removed, find_dotenv('/absolute/path/.env', usecwd=True) raises FileNotFoundError even when that file exists. An absolute filename can also unnecessarily depend on caller-frame discovery.

Check fully absolute paths directly after expanding ~. Keep the existing file/FIFO check and missing-file return/exception behavior. Relative-path searching, including Windows rooted paths without a drive, stays on the original path.

Validation on Linux, Python 3.12.14:

  • Original source: 10 new regression cases fail, 2 Windows-path compatibility cases pass.
  • Final full suite: 300 passed, no skips (baseline: 288 passed).
  • Tox lint: Ruff lint/format and all five mypy targets, Python 3.10–3.14, passed.
  • Exact check-manifest, coverage reporting, both pinned pre-commit hooks, strict MkDocs build and git diff --check passed.
  • Regressions include a real deleted working directory, expanded home paths, missing files, directories and FIFOs. Windows rooted-path behavior is exercised with standard-library Windows path semantics; this is not a native Windows run.

Prepared and tested with OpenAI Codex assistance, including an independent automated review. No human review or hosted CI pass is claimed.

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 8, 2026 06:12

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