我试图实施一些简单的python格式规则。我找到了pylint
,我很高兴。然而,我需要执行的一个更简单的格式检查是:仅制表符或仅空格缩进。
在pylint
中,如何启用制表符或空格缩进的错误或警告?
我看到pylint
有{a1}。但是w0311
不只强制制表符或空格。。。它仍然支持制表符或空格。
我需要我所有的python文件都是一种缩进类型。
(二)
另外,如果您想知道我是如何使用pylint
来执行我的规则的。我有一个运行pylint
的shell脚本,我使用set -o errexit
,这与构建挂钩。因此,如果pylint
发现了某个非零值的东西,它就会退出并导致构建失败。
)
你要找的可能是:
mixed-indentation (W0312): Found indentation with %ss instead of %ss Used when there are some mixed tabs and spaces in a module.
在以下情况下引发:
编辑1:
据我所知(目前为止),Pylint没有一个选项来“强制”您的编码风格中的制表符/空格。上面提到的W0312用于警告代码中的缩进不一致。在
我用一个技巧来强制缩进:在PyCharm上打开你的项目(在社区版也是免费的)如果IDE检测到不一致,它会警告你,它会给你一个选项来更改当前文件的缩进,或者保持它的原样!在
相关问题 更多 >
编程相关推荐