black
black copied to clipboard
Black and flake8 no longer in sync
Describe the bug
Empty classes now format differently between black and what flake8 expects:
To Reproduce
class Foo:
...
Reformats with the latest black to:
class Foo: ...
Which then flails flake8 with:
E701 multiple statements on one line (colon)
Expected behavior
Flake8 and black should be compatible in accordance with guidance at: https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
Environment
- Black's version: 24.1.0
- OS and Python version: Python 3.10.13
- flake8 --version: 6.1.0 (mccabe: 0.7.0, pycodestyle: 2.11.1, pyflakes: 3.1.0) CPython 3.10.13 on Linux
Additional context
Related to #3887. Looks like this is an intentional change as per #4066, and disabling e701 should be documented.
It turns out that the same change also triggers pylint issues:
C0321: More than one statement on a single line (multiple-statements)
Please send a PR to https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html documenting that these formatting rules should be disabled.
In general, I'd recommend disabling all formatting-related rules from linters if you use Black. It's Black's job to worry about minutiae of formatting, not yours.