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 lines in type hints that use '|' operator. #3816

Closed
dusktreader opened this issue Jul 27, 2023 · 1 comment
Closed

Black breaks lines in type hints that use '|' operator. #3816

dusktreader opened this issue Jul 27, 2023 · 1 comment
Labels
T: style What do we want Blackened code to look like?

Comments

@dusktreader
Copy link

Describe the style change

Currently, black will break a long line that uses a | character for type hints after the | character resulting is very unsightly code.

If it is possible to break the line after the type hints to stay within the line limit, black should leave the type hints on a single line.

Examples in the current Black style

def foo(
    bar: Baz
    | None = Baz(
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor...",
        language=Latin,
    ),
):
    pass

Desired style

def foo(
    bar: Baz | None = Baz(
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor...",
        language=Latin,
    ),
):
    pass

Additional context

This behavior causes flake8 to object over w503.

@dusktreader dusktreader added the T: style What do we want Blackened code to look like? label Jul 27, 2023
@JelleZijlstra
Copy link
Collaborator

Duplicate of #2316

@JelleZijlstra JelleZijlstra marked this as a duplicate of #2316 Jul 27, 2023
@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

2 participants