On Sun, 8 May 2022, at 7:11 AM, Sebastian Berg wrote: > To be fair to black, the main issue there is the trailing `,` which > forces items to be formatted on a line each (yapf does the same). > If you remove the trailing comma, you will get close to what you want > also in black: > > custom_colormap, label_color_index = color_dict_to_colormap( > self.color, even, more, options > )
No, black added those parentheses and the trailing comma all by itself, and cannot be persuaded otherwise (believe me, I've tried). Perhaps your test didn't show it because you were missing that our line length is configured to 79c. **Update** Whoa, this is actually a black version update, removing the comma fixes the formatting! :tada: This makes me very happy. :joy: > Trying around with yapf, I cannot see how you can get such "hanging > indent" without using it also for e.g. lists definitions. > There is the "continuation indent" option to get the extra indent. But > it is applies to those literals giving you: > > my_list = [ > ( > "first thing", > "second", > ), > ] > > (Of course you can tweak a few things there) Yes, what I tweak is consolidating of parentheses, so this is what I get with that construct: my_list = [( "first thing", "second" )] > Yapf is not capable of adding/removing parentheses around expressions. > So you have to do that manually on otherwise long lines. > (Not sure this is a limit that matters in practice. It is similar to > that trailing comma magic that also requires some manual care.) Yeah in my experience it's been fine. > Mind sharing your yapf config Juan? Here it is: https://github.com/jni/skan/blob/0ff5677461068e036ab6641729635cd651aaa87c/.style.yapf > regardless of quality of formatting versus black, [yapf] generally has not > had the resources to keep up with new releases of Python. That's sad to hear, and I'll happily acknowledge, a major drawback. Juan. _______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com