我正在浏览我的RC文件,我无法为我的生活寻找哪些变量禁用该功能。Pylint:在“返回”(无其他返回)警告后禁用不必要的“其他”警告
我搜索了“if”,“else”和“return”,我什么也没看到。除非我错过了它。
谢谢。
更多信息
pylint 1.7.2,
astroid 1.5.3
Python 2.7.10 (default, Jul 30 2016, 18:31:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
我把什么到终端
pylint --rcfile=.pylintrc Test.py
测试代码
""" Module Docstring """
def IS_POSITIVE(number):
""" detects positive """
if number > 0:
return "+++"
else:
return "---"
print IS_POSITIVE(3)
打印出来
************* Module Test
R: 27, 4: Unnecessary "else" after "return" (no-else-return)
------------------------------------------------------------------
Your code has been rated at 8.00/10 (previous run: 8.00/10, +0.00)
一个选择是听取和删除“else”子句,只是“return”---“'。有一个[问题](https://stackoverflow.com/questions/9191388/it-is-more-efficient-to-use-if-return-return-or-if-else-return)关于哪些是在Python中是首选,我不认为有明确的答案,但似乎pylint在“没有其他”方面权衡。 –
是的,我知道,我已经采取了改变代码来做到这一点,但它仍然让我感到困惑。 Tams Hegedus通过指出,我应该简单地添加“no-else-return = no”来关闭此选项,但它仍然无效。这让我感到无法结束。 – Biclops