我在名为 main.py
的文件中的以下代码上运行 pep8:
class Task(ndb.Model):
index = ndb.IntegerProperty(required = True)
description = ndb.TextProperty(required=True)
当 ~/.config/pep8
看起来像这样时:
[pep8]
ignore = W291, E251
运行$ pep8 main.py
给出以下输出:
main.py:49:41: E251 unexpected spaces around keyword / parameter equals
main.py:49:43: E251 unexpected spaces around keyword / parameter equals
main.py:51:1: W293 blank line contains whitespace
但是,当我将错误代码的顺序交换为 ignore = E251, W291
并在同一文件上运行相同的命令时,我得到:
main.py:50:50: W291 trailing whitespace
main.py:51:1: W293 blank line contains whitespace
换句话说,只有第一个 pep8 代码被忽略。真让人抓狂。我做错了什么,还是这是一个错误?
我在 Sublime Text 3 中遇到了与 Python linting 相同的问题,这是由用户定义的 SublimeLinter.sublime-settings 中的忽略参数定义的;不确定这是否相关(我正在按照 https://realpython.com/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/ 中的说明进行操作)。
谢谢!
最佳答案
问题是我的 PEP8 错误代码之间存在空格。示例配置in the documentation内容如下:
[pep8]
ignore = E226,E302,E41
关于python - pep8 仅注册 "ignore"参数中的第一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29055608/