dnanhkhoa / nb_black

A simple extension for Jupyter Notebook and Jupyter Lab to beautify Python code automatically using black.
MIT License
366 stars 41 forks source link

Permanently Enabling `nb_black` #14

Open fweth opened 4 years ago

fweth commented 4 years ago

I would really like to permanently enable nb_black in Jupyter Notebook, but unfortunately, when I put c.InteractiveShellApp.extensions = ['nb_black] in my IPython profile, I get the output <IPython.core.display.Javascript object> after each line of evaluation in IPython.

Editing ~/.local/lib/python3.7/site-packages/jupyter_core/tests/dotipython/profile_default/ipython_config.py worked as intended, but is not a very elegant solution.

Is there any possibility to specify a IPython profile which should only be used by Jupyter? Or maybe make nb_black more agnostic towards IPython, so that it only shows effect in Jupyter Notebook?

mazzma12 commented 4 years ago

Is there any possibility to specify an IPython profile which should only be used by Jupyter? Or maybe make nb_black more agnostic towards IPython, so that it only shows effect in Jupyter Notebook?

I would not recommend solution 2 as one may often switch between lab or notebook. IMO solution 1 would work, but the best would be to have one name for the extension and change the behavior depending on if it runs in Jupiter lab or notebook. That being said, I haven't look at the code, so I don't know if it is feasible