Skip to content

Accept quoted file paths in the IPython dotenv magic - #732

Open
FanWu-ai wants to merge 1 commit into
theskumar:mainfrom
FanWu-ai:fix/ipython-quoted-paths
Open

FanWu-ai wants to merge 1 commit into
theskumar:mainfrom
FanWu-ai:fix/ipython-quoted-paths

Conversation

@FanWu-ai

Copy link
Copy Markdown

Summary

IPython's POSIX argument parser preserves the quote characters used to group a filename. As a result, %dotenv "my project/app.env" reports cannot find .env file even when the file exists.

On non-Windows platforms, remove a matching pair of outer single or double quotes before looking up the file. This also lets quoted absolute and ~/ paths reach the existing path-resolution behavior. Backslashes and internal apostrophes are preserved. Windows keeps its existing native argument parsing, including literal apostrophes in filenames.

Tests

  • Integration cases load real relative, absolute, and home-directory paths containing spaces, with both POSIX quote styles and -o. Native Windows still exercises double quotes; unsupported single-quote grouping is expected to raise UsageError without changing the environment.
  • Additional cases cover Windows-style backslashes, internal apostrophes, and an actual filename with literal outer apostrophes. Three simulated Windows post-parser cases verify filenames are preserved unchanged.
  • Ten added regression cases fail against the original source; five added compatibility controls pass before and after the change.
  • Full clean baseline: 288 passed. Final full suite: 303 passed, zero skipped, on Linux/Python 3.12.14. Native Windows execution is left to hosted CI and is not claimed passed.
  • Tox lint (Ruff lint/format and mypy Python targets 3.10 through 3.14), manifest, coverage report, pinned pre-commit hooks, strict MkDocs build, isolated sdist/wheel build, and git diff --check all passed.

AI assistance: prepared and tested with OpenAI Codex, including 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 14, 2026 22:57

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