-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
F: linebreakHow should we split up lines?How should we split up lines?S: acceptedThe changes in this design / enhancement issue have been accepted and can be implementedThe changes in this design / enhancement issue have been accepted and can be implementedT: styleWhat do we want Blackened code to look like?What do we want Blackened code to look like?
Description
Context:
- When a function has many parameters, it's more readable when on multiple lines, enforcing black to wrap lines adding a comma after the last parameter.
- See https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#how-black-wraps-lines
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:
- https://docs.python.org/3/whatsnew/3.12.html#summary-release-highlights
- A generic function can now have type parameters used by the static type checker.
- See PEP 695, type parameter syntax and the type statement
- See https://peps.python.org/pep-0695/#summary-examples
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.
madebylydia, UlfurOrn, AlexandrNikitin3776, Ben-Drucker, raulparada and 20 moremcobzarenco and AndreaCensiAlexandrNikitin3776, mcobzarenco and leaver2000
Metadata
Metadata
Assignees
Labels
F: linebreakHow should we split up lines?How should we split up lines?S: acceptedThe changes in this design / enhancement issue have been accepted and can be implementedThe changes in this design / enhancement issue have been accepted and can be implementedT: styleWhat do we want Blackened code to look like?What do we want Blackened code to look like?