我使用pylint和flake8来控制代码质量。不过,我的位置不符合pylint或flake8的要求:
if (not re.search(regexp, summary) and
not re.search(regexp2, summary)):
return False 来自flake8的输出:
visually indented line with same indent as next logical line [E129] 移动返回没有帮助,前面的错误仍然发生,pylint抛出了新的错误:
if (not re.search(regexp, summary) and
not re.search(regexp2, summary)):
return False 来自pylint的输出:
[bad-indentation] Bad indentation. Found 8 spaces, expected 4 发布于 2017-02-10 12:02:36
根据佩普-8,您可以(“在这种情况下可接受的选项包括,但不限于.”)进一步缩进条件的第二行:
在条件延续行上添加了一些额外的缩进。if (this_is_one_thing和that_is_another_thing):do_something()
不同之处在于,延拓行中的缩进是纯文体的,而下一个代码块的缩进具有语义意义。就你而言:
if (not re.search(regexp, summary)
and not re.search(regexp2, summary)):
return False 注意,我已经按照相同的指南移动了and。
https://codereview.stackexchange.com/questions/154997
复制相似问题