Change configuration of Python linter and fixer with ALE (nvim plugin)

Viewed 2957

I use ALE to manage my linting (with flake8) and code formatting (with black). One annoying incompatibility between flake8 and black is that flake8 gives an error when a line has more than 80 characters, while black only corrects lines with more than 88 characters.

So I would like to change flake8's line length to 88 characters, or change black's line length to 80 characters.

Notice that I do not have flake8 installed independently from ALE, but I do have black installed independently from ALE.

2 Answers

You can add the below to your .vimrc file:

let g:ale_python_flake8_options = '--max-line-length=88'

You can just modify the flake8.vim in:

~/.vim/plugged/ale/ale_linters/python/

folder and change line:

call ale#Set('python_flake8_options', '')

into:

call ale#Set('python_flake8_options', '--config=$HOME/.config/flake8')

Then add all config options in this file.

Related