kynan / nbstripout

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

Add an --drop-tagged-cells="some tags" Option #161

Closed boun closed 2 years ago

boun commented 2 years ago

Hi,

the present pull request adds an apparatus to skip entire cells based on a list of tags that can be passed as command line argument.

It might be unappropriate to suggest such a feature to a tool, that indicates in its name that it strips output only. Having said that, there is already an option that strips empty cells entirely. Therefore I leave the decision up to you :)

My use case is, that I create lots of exercise notebooks for students. Clearing the solution is manual and error-prone labor. With this patch applied a simple makefile can convert solutions to exercises and (unrelated to this tool) convert solutions to a pdf.

Tests pass an I added an additional one.

boun commented 2 years ago

Hi,

thanks for the review! I was unaware that strip() can be used without argument. Again what learned! Changes followed your requests. One thing that I noticed is that one additional (?) test is failing unrelated to my changes (well, I think I did not break it).

platform darwin -- Python 3.9.9, pytest-6.2.5, py-1.11.0, pluggy-1.0.0

...

FAILED nbstripout/_nbstripout.py::FLAKE8 - AttributeError: '_io.StringIO' object has no attribute 'buffer'
kynan commented 2 years ago

Btw. the test failure is tholo/pytest-flake8#81 and unrelated to your changes. I've attempted to force flake8 to version 3.9.2 in aa7dad1. Can you rebase on master again?