10

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.

Soap
  • 309
  • 2
  • 14
  • you probably want to configure flake8 and/or black via their configuration files – anthony sottile Aug 12 '20 at 04:40
  • @AnthonySottile The problem is that I do not find flake8's config file where it would normally be since I did not install it outside ALE, and black does not have such config file as far as I understand from the documentation - it only let's you set a custom line length when ran from the command line. – Soap Aug 12 '20 at 10:55
  • I'm the maintainer of flake8, you can configure it with either a `.flake8`, `setup.cfg`, or `tox.ini` file. for black you configure it using `pyproject.toml` – anthony sottile Aug 12 '20 at 16:50
  • @AnthonySottile Thank you, I used pyproject.toml with line-length = 80 and it worked. – Soap Aug 12 '20 at 21:42

2 Answers2

14

You can add the below to your .vimrc file:

let g:ale_python_flake8_options = '--max-line-length=88'
Brett Monroe
  • 151
  • 1
  • 7
0

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.