Skip to content

Fix %foo? parsing in IPython assignment expressions#24152

Merged
charliermarsh merged 1 commit intomainfrom
charlie/help
Mar 24, 2026
Merged

Fix %foo? parsing in IPython assignment expressions#24152
charliermarsh merged 1 commit intomainfrom
charlie/help

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh commented Mar 24, 2026

Summary

We now distinguish between IPython escape commands lexed after an = sign from those at the start of a logical line, which allows x = %foo? to be interpreted as "assign the result of running a line magic named foo?", matching the IPython assignment-magic transform.

See: #21705 (comment).

@charliermarsh charliermarsh added the parser Related to the parser label Mar 24, 2026
@charliermarsh charliermarsh changed the title Fix %foo? parsing in IPython assignment expressions Fix %foo? parsing in IPython assignment expressions Mar 24, 2026
@charliermarsh charliermarsh marked this pull request as ready for review March 24, 2026 03:33
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 24, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@dhruvmanila dhruvmanila self-assigned this Mar 24, 2026
}
continue;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we add a comment explaining what we're handling here? Given the !context.allows_help_end, I assume this isn't a help end (but the comment above explains that we're lexing help end tokens here)

@charliermarsh charliermarsh enabled auto-merge (squash) March 24, 2026 13:10
@charliermarsh charliermarsh merged commit fcef46c into main Mar 24, 2026
45 checks passed
@charliermarsh charliermarsh deleted the charlie/help branch March 24, 2026 13:14
carljm added a commit that referenced this pull request Mar 25, 2026
* main:
  [ty] Avoid eager TypedDict diagnostics in `TypedDict | dict` unions (#24151)
  `F507`: Fix false negative for non-tuple RHS in `%`-formatting (#24142)
  [ty] Update `SpecializationBuilder` hook to get both lower/upper bounds (#23848)
  Fix `%foo?` parsing in IPython assignment expressions (#24152)
  `E501`/`W505`/formatter: Exclude nested pragma comments from line width calculation  (#24071)
  [ty] Fix Salsa panic propagation (#24141)
  [ty] Support `type:ignore[ty:code]` suppressions (#24096)
  [ty] Support narrowing for extended walrus targets (#24129)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parser Related to the parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants