在 iPython notebook 代码中验证 PEP8 [英] Verifying PEP8 in iPython notebook code
本文介绍了在 iPython notebook 代码中验证 PEP8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种简单的方法可以检查正在编写的 iPython 笔记本代码是否符合 PEP8?
Is there an easy way to check that iPython notebook code, while it's being written, is compliant with PEP8?
推荐答案
如果这对任何人有帮助,我正在使用:
In case this helps anyone, I'm using:
conttest "jupyter nbconvert notebook.ipynb --stdout --to script | flake8 - --ignore=W391"
conttest
在保存对笔记本的更改时重新运行flake8 -
告诉 flake8 从标准输入获取输入--ignore=W391
- 这是因为jupyter nbconvert
的输出似乎总是有一个文件末尾的空白行",所以我没有想让 flake8 抱怨一下.
conttest
reruns when saving changes to the notebookflake8 -
tells flake8 to take input from stdin--ignore=W391
- this is because the output ofjupyter nbconvert
seems to always have a "blank line at end of file", so I don't want flake8 to complain about that.
我在使用 Markdown 单元格时遇到问题(不过,其行长可能很长):使用`--to script`忽略`jupyter nbconvert`中的markdown单元.
I'm having a problem with markdown cells (whose line lengths may legitimately be quite long, though): ignore markdown cells in `jupyter nbconvert` with `--to script`.
这篇关于在 iPython notebook 代码中验证 PEP8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文