编写预提交,*检查是否已清除jupyter笔记本电脑的输出



我知道您可以使用jupyter nbconvert --clear-output --inplace <file>(根据此处(清除jupyter笔记本的输出。我想知道是否有一种简单的方法可以检查是否在预提交挂钩中清除了输出。这样,如果预提交没有失败,我可以使其失败,并迫使用户重试。谢谢

您可以使用nbstripout作为预提交挂钩。

repos:
- repo: https://github.com/kynan/nbstripout
rev: 0.5.0
hooks:
- id: nbstripout

您可以使用--dry-run对其进行修改,以不修改任何文件。不过我还没试过。

最新更新