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

Inconsistent formatting around power and brackets #15130

Open
tobiasdiez opened this issue Dec 24, 2024 · 1 comment
Open

Inconsistent formatting around power and brackets #15130

tobiasdiez opened this issue Dec 24, 2024 · 1 comment
Labels
formatter Related to the formatter style How should formatted code look

Comments

@tobiasdiez
Copy link

The expression

rho = sqrt(r**2 + a**2 * cos(th)**2)

is reformatted (ruff format) as

rho = sqrt(r**2 + a**2 * cos(th) ** 2)

Note the additional space around ** after the cosine.

@AlexWaygood AlexWaygood added the formatter Related to the formatter label Dec 24, 2024
@AlexWaygood
Copy link
Member

Thanks for the report! In general, Ruff's formatter tries to apply the same style to Python code as Black. I checked and Black applies the same style here that we do. The motivation for this formatting is described in Black's documentation here: https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-breaks-binary-operators. We've previously made chnages in the opposite direction to what you're asking for here, e.g. #7318, in order to ensure a compatible coding style with Black.

This doesn't mean that we definitely won't change the style of how we format power expressions -- we do deviate from Black in some areas. But deviations generally require very strong motivations and high levels of user demand, as we weigh compatibility with Black quite highly.

@MichaReiser MichaReiser added the style How should formatted code look label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter style How should formatted code look
Projects
None yet
Development

No branches or pull requests

3 participants