9

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

Amey
  • 2,214
  • 2
  • 19
  • 28
  • Could you please post the whole error message you are getting and the actual code where flake8 finds a warning? Thanks. – alecxe Mar 03 '14 at 18:47
  • 1
    `W0311` is actually a pylint warning ([source](http://docs.pylint.org/features.html#id3)). How do you run it? Do you have `.pylintrc` in your project directory? – alecxe Mar 03 '14 at 19:05
  • (re)edited my question to include `.pylintrc` config. Thanks again! – Amey Mar 03 '14 at 19:14

1 Answers1

0

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.

J_H
  • 17,926
  • 4
  • 24
  • 44