在iPython笔记本代码中验证PEP8 [英] Verifying PEP8 in iPython notebook code

查看:163
本文介绍了在iPython笔记本代码中验证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:

conttestjupyter nbconvert notebook.ipynb --stdout --to script | flake8 - - -ignore = W391


  • conttest 重新运行时保存对笔记本的更改

  • flake8 - 告诉flake8从stdin获取输入

  • - ignore = W391 - 这是因为 jupyter nbconvert 的输出似乎始终有一个空行文件,所以我不想让flake8抱怨。

  • conttest reruns when saving changes to the notebook
  • flake8 - tells flake8 to take input from stdin
  • --ignore=W391 - this is because the output of jupyter nbconvert seems to always have a "blank line at end of file", so I don't want flake8 to complain about that.

我遇到了降价单元格问题(其行但是,长度可能合法地很长):忽略降价单元格`jupyter nbconvert`与` - 脚本`

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笔记本代码中验证PEP8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆