New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot make multi-line code blocks in ipython #11334
Comments
you can use |
I never would have guessed that one. I'm not sure how to make this more clear, but I do think it warrants some clarification/hand-holding. I tried every shortcut I could think of and ended up forcing a downgrade to fix my issue. I use IPython to make it easier to type out and edit multi-line blocks in the REPL while teaching live audiences. I suspect others in my situation may have similar issues. Maybe a warning somewhere that indicates that Ctrl-O can be used to make a multi-line code block? I'm not sure whether there's an appropriate place for that. |
It is a bug with a recent refactor, I was just trying telling you that you can use Ctrl-O in the meantime if you wish to use 7.x |
Ah great! I'm glad it was just a bug. Thanks @Carreau! 😄 |
Would you mind giving me a few examples (working and not workig) of what you expect, in order to provide test for the fixes ? I have some but just collecting a few and don't want to influence you. |
Can't remember the second example, but a number of loops:
|
@Carreau is someone working on this issue? I'd be happy to help out |
hi @Deborah-Digges, I've had a quick look but no too much so far. I've wrote this small test case to see the difference between the old input_splitter and the new input_transformer:
Which result in
You see that the 3rd item is the one that interest us. The second was out of curiosity as one of the "feature" of IPython is to force-execute if there is more than 2 newlines. Part of the relevant code is in shortcut.py:L109-L127. I guess there is some kind of conflation between the role of defining whether a check of code is "complete", or whether we should "execute or add a new line". I'm guessing that the heuristic that check whether the input is multiline and whether the last character is already a new line or not should be sufficient. One of the remaining questions is where to put that fix ?
Let me know if that's enough to at least get you started. Thanks ! |
Hi @Carreau ! Thanks so much for the detailed explanation and test cases. I was able to reproduce it locally with the dev version of ipython and will now start looking into the code for |
You don't need a few examples. The bug occurs in very reproducible way. |
Upper case I please, we don't want trouble with apple.
Well, no I don't need, but I want multiple example. I can reproduce and have an idea of how to fix it, but having multiple case help me be sure that I'm no hitting an edge case. I do have a biased view on how to use IPython, so example from other are helpful. |
When codeop.compile_command() returns None it actually says "at least some part of the code was compiled successfully" which is not really important for checking if it's complete or not. Once we haven't got any errors during compilation process, we just want to check if there will be another nested block of code or not by checking a colon.
At least I found out why there was the the upper I in the name, thanks and sorry :) As a apology, here is a pull request #11354 that fixes this (major) issue. IMHO this is a blocking bug for IPython, you should consider to make a release soon (see how many issues is created at github by users regarding it). |
That's not the (only) reason, as IPython 0.1 was release before the first iProduct, but usually people remember
thanks I'll have a look when time allows
Yes, once a volunteer have time have we'll do that. There are other critical issue like getting a release of jupyter_console out, and I don't think anyone here can take a couple of hours on $DAYJOB to do so. So it may have to wait for this week-end. |
Actually, I got a regression with my fix. Fixing it now. |
The PR #11354 is updated now. |
Thanks for the fix, any idea when is this going to be released? I'm using vim keybindings to CTRL-O doesn't work for me (ESC + o does ...) |
That's going to be one one of the volunteer on the project get a couple of free hours to triage the few remaining issues for 7.1 and does a release. I'm hoping to maybe have a couple hours this week-end, but that may not be sufficient. Any help on triaging/reviewing/tagging the existing PRs/Issues would be helpful. |
Still reproducible with the
|
Hum, that is likely a weird interaction with autoawait. |
Oh, I didn't think it'd attach to this issue. Anyway, the reason it fails is that when we have
it runs Possible solutions/ideas:
I'm sorry for the lack of dedication, I'd submit thw PR, but I hate writing tests and whatnot and also not sure of the better way to fix that. But I hope it's still useful for someone. |
We could try something like this as well. |
That's your point nº 2, and it is indeed ugly. The newline works. What would be good is get proper support in CPython. |
Is this issue still unresolved? I think I may have caught this bug... This come up today for the first time (during a demo with a client when I was trying to demonstrate what a generator is in Python!!!). Am I doing something wrong or what am I supposed to do to write multi-line code blocks (other than CTRL-o workaround)? Expected result as demonstrated in the standard Python REPL:
Result today when I type the same into an iPython REPL:
The iPython REPL automatically indents the second line as expected. But when I type enter at the end of the second line it executes the two lines instead of providing an optional third line. As described above, I can get the desired result by pressing CTRL-o instead of pressing enter on the second line:
|
Please upgrade your IPython, this issue is solve, there is just still an edge case with async code. |
Oh sorry. I thought I did. After Sorry, I'm a bit confused. What is the latest version and how do I upgrade to it? |
It will depends on how you installed it, I would suggest to try with When things like that happend, I try to aggressively uninstall until I can't launch IPython and then reinstall. |
Is there a way to disable multiline commands? |
Is anyone working on this issue? I would be very happy to contribute. |
I just did a
pip install ipython
while teaching a class today and typed an if statement and then hit enter after the first line and the code executed.This seems like a bug.
I did a
pip install ipython==6.5.0
and hitting Enter in a code block properly showed me the next indented line to type out.I'm on Ubuntu 18.04 running ipython within tmux, though I doubt tmux is the issue here.
The text was updated successfully, but these errors were encountered: