I'm currently experimenting with the Black code formatter for Python. In >90% of the cases I am happy with the output (with default configs), but it regularly happens, that it formats some lines in a way that seems rather ugly to me.
Here an example, before and after formatting with black.
The syntax of these two lines is originally identical (same function, same number of arguments...), so it makes sense to format them in the same way. However, as the first line is slightly longer, Black formats it differently, which makes it much more difficult to read and interpret the code.
Of course, in this particular case, you could just increase the linelength
parameter of Black, but that doesn't really solve the problem in general, and I would like to stick with the default configuration.
I have come across many such situations, also using other formatters such as Prettier for JavaScript. How do you handle these situations? Is there for example a way to tell Black, to ignore these particular lines and not format them?
;¬)
– Ouzo"recall"
, black will format the second statement's arguments the way you are wanting (on separate lines). Not saying that this addresses the real problem... just pointing out that there are ways to hint toblack
what to do. – Parcae