Nbdev_build hook for black code formatter

My project uses a GitHub Build CI workflow that incorporates a black code formatter check. Is it possible to incorporate an nbdev_build hook that runs output through the black formatter before writing the .py files?

2 Likes

Would actually love to have this as a feature (maybe not just black but other formatters as well)

Have you seen https://github.com/nbQA-dev/nbQA? You could either add it as a precommit hook or run it as a GA. The only thing is you’d need to make sure you also update the export code after but you could add that as an extra step quite easily I think.

I have manually used this tool for a few projects and found it worked well so far.

1 Like

Is there any way to run them on save?
I find that at build time only it hides changes from the user (me) :sweat_smile:

Note that this (black formatting) will be a first class feature in nbdev version 2 :tada: :rocket:

We are targeting a public release at the end of July.

6 Likes