nb-clean
nb-clean copied to clipboard
Add support for clean --recursive
This is a draft implementation of --recursive to show the idea in code and get feedback from the author on willingness to merge a feature like this.
If this is something that the project would merge, a finalizing todo may include:
[ ] Adding unit tests
[ ] Add option to check
command as well
Hi @bneijt -- this is certainly something I'm willing to merge, if you'd like to add the option to the check
command and some tests. 😃
Added unit test and clean support as well, references https://github.com/srstevenson/nb-clean/issues/147
Please enable the workflow.
One thing to consider is that the current implementation does not enforce a unique set. If you call nb-clean check -r a a
you will get duplicate files, but this will be the same as getting duplicate files by just calling nb-clean check a/a.ipynb a/a.ipynb
so I don't think the code should deal with that in a special way.
@bneijt How about always expanding the arguments that are passed, and removing the --recursive
flag? This would be consistent with what most Python linters/formatters do (all of mypy, Black, isort, flake8, and pylint recurse into directories by default).
Codecov Report
Base: 97.95% // Head: 98.07% // Increases project coverage by +0.11%
:tada:
Coverage data is based on head (
6d1574e
) compared to base (0019065
). Patch coverage: 100.00% of modified lines in pull request are covered.
Additional details and impacted files
@@ Coverage Diff @@
## main #148 +/- ##
==========================================
+ Coverage 97.95% 98.07% +0.11%
==========================================
Files 3 3
Lines 147 156 +9
==========================================
+ Hits 144 153 +9
Misses 3 3
Impacted Files | Coverage Δ | |
---|---|---|
src/nb_clean/cli.py | 100.00% <100.00%> (ø) |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Sounds good to me, I can write that up tomorrow. One thing that you do need to take into account is that clean is a potentiality destructive action that you might not want to recurse automatically. But for check it makes sense.
As you are the maintainer, I leave the choice to you. I'm fine with it, most of my notebook output needs cleaning anyway ;-)
I hope that this PR supports what I hope exist in this repo, giving a folder and run nb-clean on all notebooks in the directory, see ny failed attempts in https://github.com/srstevenson/nb-clean/pull/150
The last commit makes the recursive action default behavior for both clean and check.
This is now available in nb-clean 2.3.0 on PyPI.