kynan / nbstripout

strip output from Jupyter and IPython notebooks
Other
1.19k stars 94 forks source link

Option to error on cell outputs exceeding `--max-size` #167

Open janosh opened 2 years ago

janosh commented 2 years ago

The --max-size flag added in #135 is a great addition! 👍

When using nbstripout as commit hook, it would be nice to have a slightly safer mode that doesn't auto-remove output exceeding the max size but rather raises an error to abort the commit and let the developer handle it on a case by case basis (maybe compress rather than remove the cell output).

kynan commented 1 year ago

I can definitely see that use case, however isn't the point (and mode of operation) of the pre-commit hook that it'll fail if it would make any changes to the working tree? Correct me if I'm wrong, as I don't use nbstripout in this mode, so I'm stating this based on some light testing I'd done quite a while ago and some other issues that have been raised on the pre-commit use case.

janosh commented 1 year ago

pre-commit hooks can be both linters and formatters. Formatters should fix violations themselves, linters only flag them. Any hook can also be a combination of both, i.e. fix some violations automatically and report others.

kynan commented 1 year ago

Fair enough! Are you interested in working on this @janosh ? As I don't use nbstripout in this mode I think this would ideally be implemented by someone who can test it and ensure the feature works as intended.

kynan commented 1 year ago

I won't be able to work on implementing this. Contributions welcome!