fix: strip quotes and whitespace from %env values in ipynb conversion - #10904
Merged
mscolnick merged 1 commit intoSep 21, 2026
Merged
Conversation
%env cells converted with a raw split("=", 1), so shell quoting and
surrounding whitespace leaked into the generated os.environ assignment:
%env VAR="hello world" kept the quotes in the value and %env VAR = value
produced a key with a trailing space. %env with no '=' also crashed the
transform with ValueError (caught upstream, leaving a noisy traceback and
an unconverted cell).
Mirror IPython's env-magic semantics: strip whitespace around both sides,
remove one pair of matching surrounding quotes from the value, and convert
a KEY-less form to the standard unsupported-magic comment instead of
raising.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Oscar-Williams
marked this pull request as ready for review
September 18, 2026 18:46
Bundle ReportChanges will decrease total bundle size by 83.42kB (-0.31%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: marimo-esmAssets Changed:
|
mscolnick
approved these changes
Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request was authored by a coding agent.
📝 Summary
Closes #10903
magic_envin the ipynb converter now mirrors IPython's%envsemantics: surrounding whitespace is stripped from both the variable name and the value, one pair of matching surrounding quotes is removed from the value, and a%env VARline without=converts to the standard unsupported-magic comment instead of raisingValueError. Added a regression test covering quoted values, spacedKEY = VALUEforms, the plain case, and theKEY-less form.📋 Pre-Review Checklist
✅ Merge Checklist
Validation:
tests/_convert/passes with 356 tests (including the new%envregression case);ruff checkandruff format --checkpass on the touched files;mypypasses onmarimo/_convert/ipynb/to_ir.py.