Repository navigation
Remove leading empty lines - #11718
Conversation
When running a cell, the leading indentation on the first line is removed from all of the cell's lines. This causes indentation errors on subsequent lines in case the first line consists entirely of whitespace matching a valid level of indentation that is greater than the least indented line. This change avoids the issue by first removing any leading, whitespace-only lines. Closes #11594
|
Thanks looks good to me. |
|
Thanks, other than the point about testing, this looks OK to me. |
|
I understand the interest of being able to paste code into a notebook cell and run it without having to fix the indentation, but there are also some downside to this kind of hack:
I don't think its a good idea that a notebook cell be allowed to run Python code with invalid indentation. If there is really a need to tolerate superfluous indentation when pasting, the indentation should be corrected automatically during the paste process so that if the cell runs without error, it's because the cell contains valid Python syntax. And such automatic correction behavior should ideally be optional. Just my 2c. |
|
Happy to make it optional, but someone would have to send patches to IPython/IPykernel to have the relevant configuration hooks. |
When running a cell, the leading indentation on the first line is
removed from all of the cell's lines. This causes indentation errors
on subsequent lines in case the first line consists entirely of
whitespace matching a valid level of indentation that is greater than
the least indented line.
This change avoids the issue by first removing any leading,
whitespace-only lines.
Closes #11594