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

2

12

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.

Blunge answered 11/8, 2020 at 11:2 Comment(4)
you probably want to configure flake8 and/or black via their configuration filesCrean
@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.Blunge
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.tomlCrean
@AnthonySottile Thank you, I used pyproject.toml with line-length = 80 and it worked.Blunge
B
17

You can add the below to your .vimrc file:

let g:ale_python_flake8_options = '--max-line-length=88'
Burson answered 4/11, 2020 at 22:33 Comment(0)
O
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.

Osteal answered 14/9, 2022 at 0:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.