Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black and flake8 no longer in sync #4173

Closed
daveah opened this issue Jan 26, 2024 · 3 comments · Fixed by #4194
Closed

Black and flake8 no longer in sync #4173

daveah opened this issue Jan 26, 2024 · 3 comments · Fixed by #4194
Labels
T: bug Something isn't working

Comments

@daveah
Copy link

daveah commented Jan 26, 2024

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 daveah added the T: bug Something isn't working label Jan 26, 2024
@cobaltt7
Copy link
Contributor

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

@daveah
Copy link
Author

daveah commented Jan 26, 2024

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

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

@JelleZijlstra
Copy link
Collaborator

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.

Joshix-1 added a commit to Joshix-1/typed_stream that referenced this issue Jan 26, 2024
Joshix-1 added a commit to Joshix-1/typed_stream that referenced this issue Jan 26, 2024
JonathanWillitts added a commit to clinicedc/edc-action-item that referenced this issue Feb 2, 2024
Black changes witnessed (mainly) include:
- addition of blank line between module docstrings and imports
- removal of blank lines between class declarations and docstrings
- prefer splitting assignment statements on right-hand side
- wrap conditional expressions that span multiple lines in parens
- put `...` in stubs on same line
- add E701 and E704 to flake8 ignore list, see:
    - https://github.com/psf/black/blob/main/docs/guides/using_black_with_other_tools.md#e701--e704
    - psf/black#3887 (E704)
    - psf/black#4173 (E701)
JonathanWillitts added a commit to clinicedc/edc-visit-schedule that referenced this issue Feb 2, 2024
Black changes witnessed (mainly) include:
- addition of blank line between module docstrings and imports
- removal of blank lines between class declarations and docstrings
- prefer splitting assignment statements on right-hand side
- wrap conditional expressions that span multiple lines in parens
- put `...` in stubs on same line
- add E701 and E704 to flake8 ignore list, see:
    - https://github.com/psf/black/blob/main/docs/guides/using_black_with_other_tools.md#e701--e704
    - psf/black#3887 (E704)
    - psf/black#4173 (E701)
JonathanWillitts added a commit to clinicedc/edc-visit-tracking that referenced this issue Feb 2, 2024
Black changes witnessed (mainly) include:
- addition of blank line between module docstrings and imports
- removal of blank lines between class declarations and docstrings
- prefer splitting assignment statements on right-hand side
- wrap conditional expressions that span multiple lines in parens
- put `...` in stubs on same line
- add E701 and E704 to flake8 ignore list, see:
    - https://github.com/psf/black/blob/main/docs/guides/using_black_with_other_tools.md#e701--e704
    - psf/black#3887 (E704)
    - psf/black#4173 (E701)
JonathanWillitts added a commit to clinicedc/edc-metadata that referenced this issue Feb 2, 2024
Black changes witnessed (mainly) include:
- addition of blank line between module docstrings and imports
- removal of blank lines between class declarations and docstrings
- prefer splitting assignment statements on right-hand side
- wrap conditional expressions that span multiple lines in parens
- put `...` in stubs on same line
- add E701 and E704 to flake8 ignore list, see:
    - https://github.com/psf/black/blob/main/docs/guides/using_black_with_other_tools.md#e701--e704
    - psf/black#3887 (E704)
    - psf/black#4173 (E701)
JonathanWillitts added a commit to clinicedc/edc-model that referenced this issue Feb 2, 2024
Black changes witnessed (mainly) include:
- addition of blank line between module docstrings and imports
- removal of blank lines between class declarations and docstrings
- prefer splitting assignment statements on right-hand side
- wrap conditional expressions that span multiple lines in parens
- put `...` in stubs on same line
- add E701 and E704 to flake8 ignore list, see:
    - https://github.com/psf/black/blob/main/docs/guides/using_black_with_other_tools.md#e701--e704
    - psf/black#3887 (E704)
    - psf/black#4173 (E701)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants