black icon indicating copy to clipboard operation
black copied to clipboard

Black and flake8 no longer in sync

Open daveah opened this issue 1 year ago • 3 comments

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

daveah avatar Jan 26 '24 13:01 daveah

Related to #3887. Looks like this is an intentional change as per #4066, and disabling e701 should be documented.

cobaltt7 avatar Jan 26 '24 13:01 cobaltt7

It turns out that the same change also triggers pylint issues:

C0321: More than one statement on a single line (multiple-statements)

daveah avatar Jan 26 '24 14:01 daveah

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.

JelleZijlstra avatar Jan 26 '24 15:01 JelleZijlstra