Replies: 1 comment
-
Hey @cgadal Thanks for your feedback. We received similar feedback around formatting python code in the scientific community in the Formatter Beta. Our main focus for now is compatibility with black instead of innovating a new formatters style, but we'll eventually look into how Ruff can better format complex mathematical expressions (and we'll need the community's feedback to achieve this). But for now, changing the way mathematical expressions isn't formatted. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all, thanks for the great work, ruff is amazing.
However, I have not been able to fully move to ruff since, like black, it does not seem to handle mathematical expressions properly. See here and here.
This is why I moved to
yapf
in the first place, using their knobARITHMETIC_PRECEDENCE_INDICATION
.For example,
a = np.sqrt(1*2 + 3/5+ (3 +1/5)**(1/(1+3)))
is formatted as:a = np.sqrt(1 * 2 + 3 / 5 + (3 + 1 / 5) ** (1 / (1 + 3)))
using ruffa = np.sqrt(1*2 + 3/5 + (3 + 1/5)**(1 / (1+3)))
using yapf withARITHMETIC_PRECEDENCE_INDICATION = true
I can configure VS Code to fix violations on-save using Ruff, then re-format with yapf, using the similar steps indicated in the doc for Black.
However, I'd like to stick to ruff-only ?
How can I achieve this ?
Beta Was this translation helpful? Give feedback.
All reactions