Indentation configuration in flake8

My project uses a width of 4 spaces for indentation.

However, running flake8 on it gives warnings that say the expected tab / indent width was 2 spaces.

How to configure flake8 to correctly receive 4 spaces for indentation?

class Foo(object): bar = True 

The above is my (more simplified) code snippet flake8 flags line # 2 with a warning:

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

I am using vim with the flake8 plugin.

In my .pylintrc :

 [FORMAT] indent-string=' ' 

However, I'm not sure how .pylintrc even .pylintrc into the picture, since the listing is done by the flake8 vim plugin

+6
source share
1 answer

Confirm with cat -v foo.py that no TAB has crept into your sources, where you thought there would be only spaces.

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

 $ flake8 foo.py 

Make sure that there is no .pylintrc or flake8.rc file when executing this file, so it works with the default setting. Also, make sure that in foo.py there is no two-dimensional indentation of the code that flake8 can accept and use by default.

0
source

All Articles