deathbeds / prenotebook

pre-commit hooks for the notebook
1 stars 1 forks source link

Run only in notebooks that have a python kernel #7

Open ocefpaf opened 3 years ago

ocefpaf commented 3 years ago

When mixing Python and R notebooks in the same repository it can be cumbersome to add them to an exclude list. It would be nice if the pre-commit would only run on notebooks that have a Python kernel.

The problem will persists with notebooks that use other languages magics but that skipping those is too much to ask :smile:

bollwyvl commented 3 years ago

Thanks for all the helpful feedback, sorry we haven't gotten around to spending more quality time with this project.

There's probably a lot of things that would end up wanting to be customized for this to be a real tool, but ideally not part of this repo, per se (e.g. formatters, etc. for other languages).

Probably the right thing for us to do is get a bit less opinionated and have a config file that let a project specify

As to the actual location of the config file:

As to the format of writing the rules, etc:

Then there'd be the actual commands. We'd want to special-case python so we can run some things in-loop, but generally expect to run sane shell commands.

Also, hadn't reviewed the landscape in a while, but there's mdformat which would be a lower-barrier entry for a python-native (myst|gfm) markdown formatter, which is probably good enough and would be much faster than spinning up prettier for each cell (takes a truly horrendous amount of time)... prettier would just become another cmd, and it's up to you to get your $PATH and $HOME in order.

With proper caching, this could even become a run-time tool, as any/all of:

bollwyvl commented 3 years ago

Man, that mdformat stable is deep... grayskull might need a workout on this.

ocefpaf commented 3 years ago

mdformat looks quite promising!