-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Recent updates of black have introduced out-of-the-box support for Jupyter Notebooks, which is extremely helpful. As of #2630 only known python cell magics are processed (see e.g. here), which certainly makes sense. We have the use case that we have several custom python cell magics that we would also like to process.
This request is to allow configuration to support additional (user-defined) magics.
Possible solutions:
I am aware that we could certainly call black from python directly and programmatically update PYTHON_CELL_MAGICS
to include our custom python magics. However, I'm not keen on doing this because it would depend on implementation details within black. If this would be the preferred solution, then I would suggest to at least add a function that could be called to register the additional magics.
Another possibility would be to add a configuration flag/option (i.e. in pyproject.toml
/CLI) that would allow the input of a list of additional python cell magic names. (Using an environment variable would be a similar option, but I don't see any other place that this is done, other than with e.g. XDG_CACHE_HOME
which is a more "global" configuration variable.) This is likely my preferred solution, but, given that black makes a concerted effort to avoid configuration options, I could understand why this would not be acceptable.
Thanks in advance for any input/consideration.