fix: recognize cell magics after comments 🤖🍆 - #15316
#15316fix: recognize cell magics after comments 🤖🍆#15316tianrking wants to merge 4 commits intoipython:mainipython/ipython:mainfrom tianrking:agent/recognize-comments-before-cell-magicstianrking/ipython:agent/recognize-comments-before-cell-magicsCopy head branch name to clipboard
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 432a1dba2f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,6 @@ | ||
| Leading comments before cell magics | ||
| ================================== |
There was a problem hiding this comment.
Lengthen the reST heading underline
The docs workflow builds with SPHINXOPTS="-W" in .github/workflows/docs.yml, and docutils/Sphinx reports a fatal “Title underline too short” warning when the underline is shorter than the heading. This heading is 35 characters but the underline has 34 = characters, so the new release-note fragment will fail the docs job; add one more =.
Useful? React with 👍 / 👎.
| leading_comment_lines, | ||
| classic_prompt, | ||
| ipython_prompt, |
There was a problem hiding this comment.
Run comment stripping after prompts
When users paste a prompted transcript with a leading comment before a cell magic, such as In [1]: # setup followed by ...: %%time, this cleanup pass sees the unstripped prompt and returns unchanged; after ipython_prompt/classic_prompt remove the prompts, leading_comment_lines is not run again, so %%time still falls through to EscapedCommand as an invalid %time line magic. Since prompted input is explicitly handled by these cleanup transforms, place this pass after prompt stripping or otherwise re-check after prompts are removed.
Useful? React with 👍 / 👎.
c3f02d5 to
d0c4066
Compare
|
@tianrking if this is an automated PR can you run autoformatting ? See Ci failure. |
…ments-before-cell-magics # Conflicts: # IPython/core/inputtransformer2.py
|
This branch needs rebase as it conflicts with main now. |
Summary
%%timecellRoot cause
Cell-magic detection only examined the first physical line. A leading comment left
%%timeto the escaped-command transformer, which then attempted to invoke an invalid%timeline magic.Fixes #15312
Validation
python -m pytest tests/test_inputtransformer2_line.py tests/test_inputtransformer2.py -q(66 passed)python -m compileall -q IPython/core/inputtransformer2.py🤖🍆