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 breaks the type annotation into multiple lines when it's possible to keep it on one line #1765

Open
passichenko opened this issue Oct 15, 2020 · 4 comments
Labels
F: linebreak How should we split up lines? T: bug Something isn't working T: style What do we want Blackened code to look like?

Comments

@passichenko
Copy link

Describe the bug

black breaks the type annotation into multiple lines, while existing formatting keep it on one line by using parentheses around expression

To Reproduce:

old formatting:

class Foo:
    def foo(self):
        if True:
            content_ids: Mapping[str, Optional[ContentId]] = (
                self.publisher_content_store.store_config_contents(files)
            )

after black:

class Foo:
    def foo(self):
        if True:
            content_ids: Mapping[
                str, Optional[ContentId]
            ] = self.publisher_content_store.store_config_contents(files)

playground link: https://black.now.sh/?version=stable&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4AEZAK5dAD2IimZxl1N_WlXnON2nzNX9HFvHx6cBSdVHWyzJO6O50DK3ha9hxTlR0JwlWYXCXbF4CjYJWeEpyQIXtrrOkKmzjEkT25z6cJ4YzWm7pHh_LmznKdvIU8f2vDLKjoyxv-ZPlxXoOnqhPz8sGlioAQx7_azDc47CPs6gbJw5n5j0LZ-lBGbWsnS8ldMWJXrmleKBm2qB_EmzBNy6IQNsCElvvBmM-J3BIWV55zK6IAAAAAMi_lQVqdYNAAHKAZoCAAARFT-fscRn-wIAAAAABFla

Expected behavior
black keeps existing formatting

Environment:

  • Version: both stable and master
  • OS and Python version: Linux/Python 3.7.5+

Does this bug also happen on master?
Yes.

@passichenko passichenko added the T: bug Something isn't working label Oct 15, 2020
@JelleZijlstra JelleZijlstra added T: style What do we want Blackened code to look like? F: linebreak How should we split up lines? labels May 30, 2021
@lnking81
Copy link

Will it be fixed? Very annoying, actually

@ichard26
Copy link
Collaborator

Eventually yes, but we can't really make guarantees for when as no one is being paid to work on this project.

@lnking81
Copy link

Sure, I understand. Just wonder if you pay any attention to the issues opened years ago.

@felix-hilden
Copy link
Collaborator

Just for housekeeping and eventual implementation, this is likely closely related to #749.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: linebreak How should we split up lines? T: bug Something isn't working T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

5 participants