[英]Indentation configuration in flake8
My project uses a width of 4 spaces for indentation. 我的项目使用宽度为4的空格进行缩进。
However, running flake8 on it yields warnings that say that expected tab/indentation width was 2 spaces. 但是,在它上面运行flake8会产生警告,表示预期的制表符/缩进宽度为2个空格。
How do I configure flake8 to correctly accept 4 spaces for indentation? 如何配置flake8以正确接受4个空格进行缩进?
class Foo(object):
bar = True
Above mentioned is my (over simplified) code fragment flake8 flags line #2 with a warning saying: 上面提到的是我的(过度简化的)代码片段flake8标记第2行,警告说:
[W0311] Bad indentation. Found 4 spaces, expected 2
I am using vim with flake8 plugin. 我正在使用带有flake8插件的vim。
In my .pylintrc
: 在我的
.pylintrc
:
[FORMAT]
indent-string=' '
However, I am not sure how .pylintrc
even comes into picture, since the linting is done by the flake8 vim plugin 但是,我不确定
.pylintrc
是如何.pylintrc
,因为linting是由flake8 vim插件完成的
Verify with cat -v foo.py
that no TABs have crept into your sources where you believed there would be only SPACEs. 用
cat -v foo.py
验证没有TAB进入您认为只有cat -v foo.py
的源。
You run flake8 from within vim, but during testing also run it from the command line: 您从vim中运行flake8,但在测试期间也从命令行运行它:
$ flake8 foo.py
Ensure that there is no .pylintrc or flake8.rc config file when you do that, so it is running with default config. 确保在执行此操作时没有.pylintrc或flake8.rc配置文件,因此它使用默认配置运行。 Also, verify there is no two-space indenting of code within foo.py which flake8 could sense and use as default.
另外,验证foo.py中没有两个空格缩进代码,flake8可以将其作为默认值进行检测和使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.