Help end syntax + line magic interaction
- Dominant language
- Python
- Stars
- 16.8k
- Forks
- 4.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 6
Description
The help end syntax takes higher precedence than the line magic syntax; this is [intentional](https://github.com/ipython/ipython/blob/dd7f1e1894395f59649a84f94af8c9710202b08f/IPython/core/inputtransformer2.py#L467):
# This needs to be higher priority (lower number) than EscapedCommand so
# that inspecting magics (%foo?) works.
However, if a line magic is handling text that may end in a `?` or `??`, this can lead to unexpected results -- `%somemagic whatever?` leading to ``Object `whatever` not found.`` instead of the line magic ever being called. (In my case I can tell users to just add a space after the `?`, but this isn't necessarily general.)
**Proposed solution**: if a line magic line ends in `?`/`??`, only call the help transform if there is no whitespace intervening between the `%` and the help end marker. As far as I can see this should handle the intended case for using `%` and `?` together as well as let line magics work right in general, but maybe I'm missing something. (If it is this simple I can submit a PR, implementing it looks straightforward.)
Contributor guide
Assessment
This issue has not been assessed yet.