Pylint 无法检测到缺少的 space 在 # 注释符号和缺少空行之后,Python3
Pylint cannot detect the missing space after # sign of comments and missing blank line, Python3
我写了一个 try_pylint.py
文件来尝试 pylint
是否可以用 Python 3.10 检测到一些不正确的样式。
"""This is a try for pylint detection.
"""
#hello world! --> missing a space, and it has only 1 (needs 2) blank line before it.
def print_hello():
"""print it
"""
print('hello')
如果我运行终端pylint try_pylint.py
中的命令,它给出
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
但是,如果我使用flake8
,它可以同时检测到它们。
flake8 try_pylint.py
给出
try_pylint.py:4:1: E265 block comment should start with '# '
try_pylint.py:6:1: E302 expected 2 blank lines, found 1
你能告诉我如何配置 pylint 来检测它们吗?顺便说一下,我正在使用 VS Code 开发 Python 代码。如果你能告诉我如何在 VS Code 上配置它,那就太好了。
提前致谢!
实际检查是由 pycodestyle
在 flake8 中完成的。 pylint 一般不检查这个和格式化(因为 black 可以自动格式化你的代码,这种检查不再很有用)。
black、flake8和pylint应该一起使用,它们并不相互排斥。
关于 Pylint
中注释处理的注意事项:有一个 pylint
检查器可以显示代码中空注释的消息。 message/checker 称为 empty-comment
。
我写了一个 try_pylint.py
文件来尝试 pylint
是否可以用 Python 3.10 检测到一些不正确的样式。
"""This is a try for pylint detection.
"""
#hello world! --> missing a space, and it has only 1 (needs 2) blank line before it.
def print_hello():
"""print it
"""
print('hello')
如果我运行终端pylint try_pylint.py
中的命令,它给出
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
但是,如果我使用flake8
,它可以同时检测到它们。
flake8 try_pylint.py
给出
try_pylint.py:4:1: E265 block comment should start with '# '
try_pylint.py:6:1: E302 expected 2 blank lines, found 1
你能告诉我如何配置 pylint 来检测它们吗?顺便说一下,我正在使用 VS Code 开发 Python 代码。如果你能告诉我如何在 VS Code 上配置它,那就太好了。
提前致谢!
实际检查是由 pycodestyle
在 flake8 中完成的。 pylint 一般不检查这个和格式化(因为 black 可以自动格式化你的代码,这种检查不再很有用)。
black、flake8和pylint应该一起使用,它们并不相互排斥。
关于 Pylint
中注释处理的注意事项:有一个 pylint
检查器可以显示代码中空注释的消息。 message/checker 称为 empty-comment
。