Black has syntax error with valid iPython magic when using --pipe
See original GitHub issueTo reproduce:
This occurs on black, version 19.10b0
and ‘jupytext==1.5.2’. When --sync a notebook to py:percent format using the following command:
jupytext --update-metadata '{"jupytext":{"notebook_metadata_filter":"all", "cell_metadata_filter":"-all"}, "accelerator":"GPU"}' --set-formats 'nb_python//py:percent,colabs//ipynb' --pipe black --pipe "sed s/[[:space:]]*\#[[:space:]]\%\%/\#\%\%/g" --pipe 'isort -' --pipe-fmt 'py:percent' --sync
I get this error:
executing black -
error: cannot format -: Cannot parse: 73:0: !~/miniconda.sh -b -p $HOME/miniconda
Now I tracked down the error, and when I change the lines ipynb to use !bash ~/miniconda.sh -b -p $HOME/miniconda
, it works just fine. Also the following lines also generated error:
error: cannot format -: Cannot parse: 78:0: !. activate habitat;```
I had to change it to
```bash
!conda . activate
I also had to change:
!./test_locally_pointnav_rgbd.sh
to
!bash ./test_locally_pointnav_rgbd.sh
TLDR: Black has issues when the first arg following ‘!’ isn’t a command, but references an executable file or another bash alias.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Built-in magic commands — IPython 8.7.0 documentation
To work properly, Magics must use a syntax element which is not valid in the underlying language.
Read more >IPython Documentation
The main issue is that a basic python setup.py install ... tionally can use colors for this, syntax highlighting source code and various ......
Read more >Xonsh Change Log - xonsh 0.13.2 documentation
Fixed error caused by unintialized Xonsh session env when using Xonsh as a ... A SyntaxError is raised when string literal concatenation is...
Read more >How to run IPython script from the command line - syntax ...
You need to name your file script.ipy. When it ends in .ipy it can contain ipython syntax. From ipython --help : Usage ipython...
Read more >Black
Black is the uncompromising Python code formatter. By using it ... If you want to format Jupyter Notebooks, install with pip install 'black[jupyter]'...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mwouts I opened a PR that solves the issue.
Thanks @Skylion007 for the fix. And for the notebook examples. Great project by the way!