kynan / nbstripout

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

Allow extra_keys as an argument when using a pre-commit hook #119

Closed likewei92 closed 4 years ago

likewei92 commented 4 years ago

Current extrakeys is only configurable through git config (--global) filter.nbstripout.extrakeys. It would be great if we can configure this when using nbstripout as part of a pre-commit hook as well!

kynan commented 4 years ago

Just to double check: do you mean pass those in as a command line argument like --extra-keys ?

likewei92 commented 4 years ago

@kynan sorry for the delayed reply - I meant being able to specify extrakeys in .pre-commit-config.yaml, though I think if you supported it in the command line you would be able to specify it in the yaml file as well (through args)

kynan commented 4 years ago

Thanks, I'll have a look whether we want to support either or both.

kynan commented 4 years ago

Can you give me some examples of extra keys you want to pass on the command line? And do you have an example notebook I could use to test?

kynan commented 4 years ago

I've implemented --extra-keys. You can use them with pre-commit e.g. as follows:

repos:
- repo: https://github.com/kynan/nbstripout
  rev: fe88889c2a68efebd48a3bf8fe909b6788d62305
  hooks:
    - id: nbstripout
      args: [--extra-keys=metadata.celltoolbar]

Feel free to reopen if this doesn't meet your needs.

likewei92 commented 4 years ago

That works, thanks!