0

I am trying to enforce formatting on .ipynb files from VSCode. My settings.json looks like this:

{
   "editor.formatOnSave": true,
   "python.formatting.provider": "black",
   "python.formatting.blackPath": "C:\\Python\\3.6.8\\Scripts\\black.exe",
}

VSCode's Python extension is installed as well as black and black[jupyter] (path above is correct). This works fine for regular .py files but not for .ipynb (nothing happen upon save).

I've tried to associate .ipynb files to Python, it didn't work either:

  "files.associations": {
     "*.ipynb": "python"
  }

Any clue ?

wecx
  • 302
  • 2
  • 10
  • Maybe duplicate of https://stackoverflow.com/questions/72103359/format-a-jupyter-notebook-on-save-in-vscode – wecx Oct 21 '22 at 13:05

1 Answers1

0

Since March 2023 / 1.77 there's built-in support for format on save for Jupyter Notebooks.

In May 2013 / 1.79 Visual Studio Code gained the option format on cell execution:

"notebook.formatOnCellExecution": true
jnns
  • 5,148
  • 4
  • 47
  • 74