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

Unsuccessful splitting into multiple lines when using generics. #4083

Closed
ismagilli opened this issue Dec 3, 2023 · 2 comments
Closed

Unsuccessful splitting into multiple lines when using generics. #4083

ismagilli opened this issue Dec 3, 2023 · 2 comments
Labels
T: style What do we want Blackened code to look like?

Comments

@ismagilli
Copy link

Describe the style change

I came across a strange formatting of the function declaration in the presence of generic typing. As a minimal example, I will give a function with one argument:

def func[T](argument: argument_type) -> return_type:
    pass

In this example, type T is not used, but you can also come up with a function in which type T is used, for example, using collections.abc.XXX[T] instead of argument_type and return_type.

It is assumed that the maximum length of the line has been changed, in this example, the value 50 is used (black -l 50 ...).

It seems to me that it is worth first trying to split arguments into several lines, and only then trying to separate generic declaration.

Examples in the current Black style

def func[
    T
](argument: argument_type) -> return_type:
    pass

Desired style

def func[T](
    argument: argument_type
) -> return_type:
    pass

Additional context

My black version:

$ black --version
black, 23.11.0 (compiled: no)
Python (CPython) 3.12.0
@ismagilli ismagilli added the T: style What do we want Blackened code to look like? label Dec 3, 2023
@JelleZijlstra
Copy link
Collaborator

Duplicate of #4071

@JelleZijlstra JelleZijlstra marked this as a duplicate of #4071 Dec 3, 2023
@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2023
@ismagilli
Copy link
Author

ismagilli commented Dec 3, 2023

I apologize for creating a duplicate. How did I not see this (#4071) issue?..

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