Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: recognize cell magics after comments 🤖🍆 - #15316

#15316
Open
tianrking wants to merge 4 commits into
ipython:mainipython/ipython:mainfrom
tianrking:agent/recognize-comments-before-cell-magicstianrking/ipython:agent/recognize-comments-before-cell-magicsCopy head branch name to clipboard
Open

fix: recognize cell magics after comments 🤖🍆#15316
tianrking wants to merge 4 commits into
ipython:mainipython/ipython:mainfrom
tianrking:agent/recognize-comments-before-cell-magicstianrking/ipython:agent/recognize-comments-before-cell-magicsCopy head branch name to clipboard

Conversation

@tianrking

Copy link
Copy Markdown

Summary

  • recognize a cell magic after leading comments and blank lines
  • add a regression test for a commented %%time cell
  • document the corrected input transformation behavior

Root cause

Cell-magic detection only examined the first physical line. A leading comment left %%time to the escaped-command transformer, which then attempted to invoke an invalid %time line 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

🤖🍆

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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
==================================

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread IPython/core/inputtransformer2.py Outdated
Comment on lines 688 to 690
leading_comment_lines,
classic_prompt,
ipython_prompt,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@Carreau
Carreau force-pushed the agent/recognize-comments-before-cell-magics branch from c3f02d5 to d0c4066 Compare July 22, 2026 16:46
@Carreau

Carreau commented Jul 23, 2026

Copy link
Copy Markdown
Member

@tianrking if this is an automated PR can you run autoformatting ? See Ci failure.

@Carreau

Carreau commented Jul 26, 2026

Copy link
Copy Markdown
Member

This branch needs rebase as it conflicts with main now.

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.

Comment lines above a cell magic make it parse as a line magic named %name, with a confusing error

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.