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

Wrapping lines of a function signature that uses the new python 3.12 generic type parameter syntax #4071

Open
Questionsdenombres opened this issue Nov 26, 2023 · 5 comments
Labels
F: linebreak How should we split up lines? S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?

Comments

@Questionsdenombres
Copy link

Context:

def func(a: int, b: int) -> int:
    return a + b 

def func(
    a: int,
    b: int,
) -> int:
    return a + b

python 3.12 new feature:

def func[T](a: T, b: T) -> T:
    return a

Example in the current Black style:
Enforcing black to wrap lines gives the ugly:

def func[
    T
](a: T, b: T,) -> T:
    return a

Desired style:

def func[T](
    a: T,
    b: T,
) -> T:
    return a + b

Additional context
python==3.12
black==23.11.0
Windows==11
VScode==1.84.2
VScode extension! Black Formatter==v2023.6.0

Credits:
Thank you for your great tool.
Patrick, Paris, France.

@Questionsdenombres Questionsdenombres added the T: style What do we want Blackened code to look like? label Nov 26, 2023
@JelleZijlstra
Copy link
Collaborator

Yes, we should change this. PR welcome!

@JackismyShephard
Copy link

What is the ETA on this?

@hauntsaninja
Copy link
Collaborator

Are you interested in making a PR?

@JackismyShephard
Copy link

Well, sadly I don't quite have the time for that right now.

@AndreaCensi
Copy link

@JackismyShephard if you need to undo what black did, try ruff: it will do exactly what you want

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? S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

5 participants