How to format short content into single line? #12983
-
In black, this print(
a,
b
) will be formatted into print(a, b) if there is NO trailing comma after I understand if there's a trailing comma or the content it too long, it should be kept like print(
a,
b,
) This happens quite often to me when I modify / remove the function arguments and I am pretty sure it's short enough to fit in a single line. Currently I have to join each lines manually to make it a single line. How can I achieve this (format short content in single line when there is no trailing comma) in Ruff? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi @failable Running |
Beta Was this translation helpful? Give feedback.
-
For new comers, here is the excellent documentation from the official website: https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules |
Beta Was this translation helpful? Give feedback.
Thanks. You want to ignore
COM812
because it enforces trailing commas everywhere. So what's happening is thatCOM812
fixes your code toZed then runs the formatter and the formatter sees the trailing comma, which is why it doesn't collapse the statement