kynan / nbstripout

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

Make nbstripout compatible with pre-commit #97

Closed rdturnermtl closed 5 years ago

rdturnermtl commented 5 years ago

This config file makes the nbstripout package compatible with the pre-commit commit hooks package. Using my fork you just need to add:

- repo: https://github.com/rdturnermtl/nbstripout
  sha: d5ebb11ad97dfc3306a4c351adabbd6c2f4dbfdd
  hooks:
    - id: nbstripout

to a .pre-commit-config.yaml in a repo to make it use nbstripout as a hook.

After merging into this repo, the new yaml config will be:

- repo: https://github.com/kynan/nbstripout
  sha: 0.3.6
  hooks:
    - id: nbstripout
kynan commented 5 years ago

This is now the 3rd pr for pre-commit. Can you elaborate how your implementation differs from #79 or #91 ?

Also see the discussion on #79: I (still) don't understand the workflow. nbstripout is not a hook, it's a non-destructive filter. What am I missing?

consideRatio commented 5 years ago

It takes a while to grasp how things work and how things differ.

My current understanding, which i think is exactly what you just said @kynan but in my words, is that this filter behavior preserves things locally, while a pre-commit hook may be used to change the file ahead of a commit and that would actually force the user to influence their notebooks locally.

So, what is preferred, filter behavior or destructive hook behavior? Filter behavior is nicer I think, but it took a while for me to get the difference ^^.

kynan commented 5 years ago

Closing this in favour of #79 which I just merged.