Question

My project uses a width of 4 spaces for indentation.

However, running flake8 on it yields warnings that say that expected tab/indentation width was 2 spaces.

How do I configure flake8 to correctly accept 4 spaces for indentation?

class Foo(object):
    bar = True

Above mentioned is my (over simplified) code fragment flake8 flags line #2 with a warning saying:

[W0311] Bad indentation. Found 4 spaces, expected 2

I am using vim with flake8 plugin.

In my .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

No correct solution

OTHER TIPS

Verify with cat -v foo.py that no TABs have crept into your sources where you believed there would be only SPACEs.

You run flake8 from within vim, but during testing also run it from the command line:

$ 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. Also, verify there is no two-space indenting of code within foo.py which flake8 could sense and use as default.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top