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

treatment of code comments inside of parentheses #3714

Open
Ricyteach opened this issue May 31, 2023 · 1 comment
Open

treatment of code comments inside of parentheses #3714

Ricyteach opened this issue May 31, 2023 · 1 comment
Labels
T: style What do we want Blackened code to look like?

Comments

@Ricyteach
Copy link

Ricyteach commented May 31, 2023

Hi, thanks for Black - it saves me a TON of time, but even more importantly, greatly reduces my mental load when writing code.

Describe the style change

I suggest maybe a code comment inside a parentheses should remain inside the parentheses.

Examples in the current Black style

Here's the actual use case I am running into today:

# this:
h_mincover_in = (3.5  # ft 
                    * 12)
# becomes:
h_mincover_in = (3.5 * 12)  # ft

Desired style

I think it should just stay nearly the same?

h_mincover_in = (3.5  # ft 
                * 12)

Additional context

This is in the context of scientific/engineering computing, so the placement of the comment representing the unit of measurement is important for understanding when reading the code.

@Ricyteach Ricyteach added the T: style What do we want Blackened code to look like? label May 31, 2023
@randolf-scholz
Copy link

randolf-scholz commented Jul 18, 2023

I would go further and say that black should not switch code/comment order at all. It is quite annoying to have black format

<codeA>  # <commentA>
<codeB>  # <commentB>

to

<codeA><codeB> # <commentA>  # <commentB>

this happens for example when using fluent interfaces. (#67 )

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