Indentation configuration in flake8
Asked Answered
H

1

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

Her answered 3/3, 2014 at 18:32 Comment(3)
Could you please post the whole error message you are getting and the actual code where flake8 finds a warning? Thanks.Evangelista
W0311 is actually a pylint warning (source). How do you run it? Do you have .pylintrc in your project directory?Evangelista
(re)edited my question to include .pylintrc config. Thanks again!Her
G
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.

Gosplan answered 4/1, 2018 at 7:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.