Open grahamwetzler opened 4 years ago
Can one not simply use the black functionality of VSCode in there?
The format document command does not appear in the command palette while in a notebook.
@grahamwetzler the black functionality in VScode only works on .py files, as far as I can tell.
In case it's useful to you, though, I've made a tool which might be helpful to you - https://github.com/nbQA-dev/nbQA. You can use it via the command-line as
python -m pip install -U nbqa
nbqa black my_notebook.ipynb
It only works via the command-line or as a pre-commit hook though, so it's certainly not a replacement for the excellent tool that black_nb
is
pre-commit example:
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.5.3
hooks:
- id: nbqa-black
EDIT: as for 2022, black
has a built-in black-jupyter
hook, so the above suggestion to use nbQA
is no longer necessary
Just leaving as another suggestion: there is a command for format_cell
available in VsCode. In Mac the shortcut is shift+option+F
Again, not a real replacement for the excelent tool that is nb_black, but better than having un-linted code 😅
https://github.com/n8henrie/jupyter-black works really well for me.
Neither
%load_ext nb_black
nor%load_ext lab_black
work with Jupyter Notebooks in Visual Studio Code. There is no error. The code just doesn't format.