jupyterlab_code_formatter
jupyterlab_code_formatter copied to clipboard
Indented magics don't parse
Checklist prior to opening an issue
- [ ] I have followed fully the installation steps laid out in the documentation site.
- [ ] I have restarted jupyterlab.
- [ ] I have read the FAQ section in the documentation site.
Describe the bug A cell containing:
if True:
%time 2+2
will throw:
Jupyterlab Code Formatter Error
Cannot parse: 2:4: %time 2+2
Diagnostic commands Please attach the output of the following commands (please format them properly)
-
pip freeze -
jupyter labextension list -
jupyter serverextension list
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
This issue is similar to this comment
Another one is
print(
'%s'
% 'foo'
)
which gets transformed to
print(
"%s"
# %# 'foo'
)
But yeah, if black accept https://github.com/psf/black/pull/2357 then, jupyterlab_code_formatter could just call black.format_cell and this and the other similar issues would be solved
https://github.com/psf/black/pull/2357 has been merged, so if/when they make a new release then this issue will be easily addressable