aleph
aleph copied to clipboard
BUG: black and flake8 have conflicting options
Describe the bug
The tools black
and flake8
have conflicting options so that make format lint
fails. These options should be configured in setup.cfg
.
To Reproduce
- Have a line longer than 100 chars
Or have lines like this:
foo = (
"some string" +
"more string"
)
or a line like this
some_var = \
"very line foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz"
- Run
make format lint
-
flake8
fails becauseblack
- All of these will cause
black
to reformat in a way that is incompatible withflake8
Long lines seem to be a tricky thing to handle with black. By default it won't redo lines that are over the max length. It is possible with the --preview setting to have long lines of text reformatted, but it also applies some other changes that I'm not so sure about.
Regardless of this it won't wrap text without spaces (urls etc). Our approach here has been to manually add a # noqa to such lines in order to prevent flake8 from failing on them. I'd be interested in any other workaround (sort of completely disabling this rule).
Some additional reading:
- https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
- https://github.com/PyCQA/flake8-bugbear
I've also created a branch to play around with possible solutions here:
- https://github.com/alephdata/aleph/tree/rosencrantz/2359-flake-black-conflict
Fixed in #2561