You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The formatter is designed to be a drop-in replacement for Black.
Specifically, the formatter is intended to emit near-identical output when run over Black-formatted code.
However, there is an extensive list of differences between the output of the two formatters. On my project, I was not able to configure ruff and black in such a way that the two would result in the same output, or even allow the output of the other to go unchanged. The diffs I saw can be seen here.
If black-compatibility or gradual migration from black is a goal, it would be very helpful to offer a mode which allows the output of black to go unchanged. Without this, transitioning between the two formatters requires synchronized changes to both the formatter and the code being formatted.
I understand this may be a non-goal, but I figured it was worth raising here since the website explicitly lists Black compatibility as a goal/feature.
The text was updated successfully, but these errors were encountered:
Is the right side of the diff there Ruff's output? If so, I think most of those are pretty clear improvements to the format. I understand it's tough to use both formatters at once though.
We are targeting Black compatibility, but it's very hard to reach 100% compatibility due to architectural differences. During the initial implementation, we spent time trying to close the gap from 99% -> 100% (e.g., #6343). I'm not sure how feasible it is to get closer. In the long term, we will probably diverge further from Black as we want to improve the produced format. Unfortunately, it's very hard to maintain multiple "modes" of the formatter, which is part of why we support a limited number of settings. I think this is a significant burden to a compatible mode as well.
Ruff's website says:
However, there is an extensive list of differences between the output of the two formatters. On my project, I was not able to configure
ruff
andblack
in such a way that the two would result in the same output, or even allow the output of the other to go unchanged. The diffs I saw can be seen here.If
black
-compatibility or gradual migration fromblack
is a goal, it would be very helpful to offer a mode which allows the output ofblack
to go unchanged. Without this, transitioning between the two formatters requires synchronized changes to both the formatter and the code being formatted.I understand this may be a non-goal, but I figured it was worth raising here since the website explicitly lists Black compatibility as a goal/feature.
The text was updated successfully, but these errors were encountered: