I have loaded black and flake8 into a poetry virtual environment. I'd like to change the default line length in black or flake8 so they agree. What is the best way to do this?
-
what have you tried so far? the configuration methodology for the tools doesn't change because you're using poetry – anthony sottile Mar 19 '20 at 17:39
3 Answers
Add a file .flake8
with the following :
[flake8]
max-line-length = 120
You can also do the same using a setup.cfg
file.

- 206
- 2
- 6
You can use pyproject-flake8 , a monkey patching wrapper to connect flake8 with pyproject.toml configuration.
or use FlakeHeaven : This project is a fork of FlakeHell.
FlakeHell and other forks of it such as flakehell/flakehell are no longer maintained and do not work with Flake8 4.0.x.

- 322
- 1
- 11
The short answer is add this to your pyproject.toml
file (assuming you are using one since you are using poetry
) and you should be good to go.
[flake8]
max-line-length = 88
extend-ignore = E203
This implies that the line length used by flake8
is set to 88
, which is also the default used by black.
I would recommend that you take a look at the Line Length section of Black's README. The above snippet is taken from there. Black's authors also explain the rationale behind the choice of the default value. They also detail alternative options to make flake8
happy.

- 318
- 2
- 5
-
4A plain `flake8` won't look into your `pyproject.toml` file. Put it into `.flake8` instead. – Tom Pohl Jun 22 '21 at 20:11
-
1