-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add Debug line functionality to Debug menu and toolbar #17888
Comments
That's a good idea to be consistent and something we could easily do with the |
@impact27, do you have other ideas about this? |
Currently, when the code following a In [1]: debug print('hello'
NOTE: Enter 'c' at the ipdb> prompt to continue execution.
Traceback (most recent call last):
File "/Users/rclary/opt/micromamba/envs/c2w_37/lib/python3.7/site-packages/IPython/core/magics/execution.py", line 960, in _run_with_debugger
deb.run(code, code_ns)
File "/Users/rclary/opt/micromamba/envs/c2w_37/lib/python3.7/site-packages/spyder_kernels/customize/spyderpdb.py", line 776, in run
super(SpyderPdb, self).run(cmd, globals, locals)
File "/Users/rclary/opt/micromamba/envs/c2w_37/lib/python3.7/bdb.py", line 575, in run
cmd = compile(cmd, "<string>", "exec")
File "<string>", line 1
print('hello'
^
SyntaxError: unexpected EOF while parsing This seems to be appropriate behavior to me; was there something else that you were thinking about or did I misunderstand your concern? |
I'd just like to avoid that error and simply forbid debugging a line if it's not valid. IPython has a way to check for complete statements with this method called |
What about |
|
I disagree with showing a traceback because users would think it's an error in Spyder. I mean, I doubt people would pay attention to the traceback. They'd probably just read the word What I propose is that before trying to run
|
I completely agree. I think we should "groom" the message. My point was only the tool
Yep. I think that's right. |
However, to reconsider my previous agreement, the result of "Run selection or current line" for an invalid code line is: In [1]: print('hello'
File "/var/folders/5v/28jqvwxs2cd5fj93gvwnykdrqc926z/T/ipykernel_70626/3871997710.py", line 1
print('hello'
^
SyntaxError: unexpected EOF while parsing Perhaps we want the debug counterpart to behave the same... |
I agree that "run line" raises a |
@ccordoba12, after reviewing #4431, I think I understand better what you mean.
|
Instead of trying to expand the current selection to reach a valid multi-line statement, I think we should simply check the current line, paste it in the console if valid but incomplete, and generate a new line expecting that it'll be completed eventually.
Agreed. |
This isn't really useful, at least if I understand you correctly. More often than not on such multi-line statements, my cursor is at the end of it (or at least not on the first line), so I'd have to navigate all the way up to the first line and then press the run line shortcut on each line until it gets to the bottom, which is around the same if not more work than just selecting the text (with the KB or mouse) and then pressing the run line shortcut once. If we're already parsing the AST, it should be fairly straightforward to extract the smallest complete statement from that, no? And we could just issue an error or just run the current line on edge cases, like we already do, for the sake of handling the vast majority of useful ones. |
@CAM-Gerlach, you already argued that point at length on issue #4431, which was the main reason it was not implemented at the end (and five years have passed since it was opened). If you need multi-line evaluation, you can easily create cells. Otherwise, I think what you propose is bad UX (and something no one else has requested): if users want to evaluate a line, then we should simply do that. |
So Spyder's menu bar has Run and Debug menus which have items for running/debugging a file and running/debugging a cell, and running the current line, but not debugging the current line. I propose adding this menu item to the Debug menu bar. Similar to running a single line, which pastes the current line into the IPython console and executes, debugging a single line can paste the line into the IPython console prepended with "debug" and thus invoke the debugger for executing the single line of code.
The text was updated successfully, but these errors were encountered: