When using the Black playground at, I found that your function was reformatted exactly like that when the line length was short enough (in particular, at 78 characters). In your example you would write instead: def example_function(Īrg_5: float = 0.0, # <- Notice the trailing comma This is now possible by adding a trailing comma to your last argument. The beauty of Black is that it chooses for you, and therefor preempts any arguments about which way is "best". I'd recommend just keeping the default settings. Long lines also make it harder to presentĬode neatly in documentation or talk slides. It also adversely affects side-by-side diff review on You can also increase it, but remember that people with sightĭisabilities find it harder to work with line lengths exceeding 100Ĭharacters. In those rare cases, auto-formatted code will exceed your allotted However, sometimes it won't be able to without breaking other rules. If you're paid by the line of code you write, you can pass In general, 90-ish seems like the wise choice. With 80 (the most popular), or even 79 (used by the standard library). Number was found to produce significantly shorter files than sticking To 88 characters per line, which happens to be 10% over 80. You probably noticed the peculiar default line length. To decrease the line length, you can use the -line-length flag as documented here:įor example: $ black -line-length 80 example.pyīlack explains the -line-length setting in more detail here: This is due to the default line length for black being longer than you'd like – 88 characters per line.
0 Comments
Leave a Reply. |