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
To configure flake8 to accept 4 spaces for indentation, you can create a .flake8 file in the root of your project, and add the following line to it:
--ignore=W0311
This tells flake8 to ignore warnings about bad indentation (W0311).
Alternatively, you can also specify the --max-line-length and --ignore command line options when running flake8.
flake8 --max-line-length=88 --ignore=W0311
Regarding your .pylintrc file, this is used by the pylint linter, not flake8, so it is not used in this case.
It is also worth noting that flake8 is a wrapper around several other linters, such as pycodestyle and pyflakes, and some of the plugins that use flake8 might use these linters separately, so you might need to configure them as well.
In case if you are using the flake8 plugin for vim, you can configure the plugin to use your desired indentation width. You can add this to your .vimrc file
let g:flake8_ignore = 'W0311'
You may want to check the documentation of the plugin you are using to see if there is any configuration option to set the indentation width.