python - 如何将 Pylint 或其他 linters 与 Jupyter 笔记本一起使用?

标签 python jupyter-notebook pylint linter

是否可以在 Jupyter Notebook 中使用 linter?

最佳答案

  • 是的,这是可能的
  • 您可以为 Jupyter Notebook 安装 pycodestyle,它类似于 pylint。 您可以在 Jupyter Notebook shell 中使用以下命令:
# install
!pip install pycodestyle pycodestyle_magic


# load
%load_ext pycodestyle_magic


# use
%%pycodestyle
def square_of_number(
     num1, num2, num3, 
     num4):
    return num1**2, num2**2, num3*

# Output
2:1: E302 expected 2 blank lines, found 0
3:23: W291 trailing whitespace

  • 检查this询问更多细节。我的回答受到链接中答案的启发。
  • 查看 this更多类似的 linters 和解决方案的问题。

关于python - 如何将 Pylint 或其他 linters 与 Jupyter 笔记本一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58207645/

相关文章:

python - 如何设置 django 多对多字段接受 null

python - pyExchange 的时区问题

python - 我该如何修复这个 mitmproxys SyntaxError?

jupyter-notebook - 使用 reveal.js 的全息 View ( Bokeh )

python - 将常量从外部文件导入到 python 中

python - TensorFlow:tf.where() 出错

Python f 字符串在终端和 jupyter 之间以不同方式处理新行

python - 如何使用 python 在表格中显示多个 jpeg 图像?

visual-studio-code - VScode (?) 中astropy 的pylint 错误不正确

python - Pipenv 和 PyLint