Auto-formatting with yapf (was: Re: Auto-formatting code with black - object now if you have a strong opinion)

Matt Harbison mharbison72 at gmail.com
Fri Jan 11 00:37:05 EST 2019


On Thu, 10 Jan 2019 13:51:12 -0500, Augie Fackler <raf at durin42.com> wrote:

>
>
>> On Jan 10, 2019, at 00:14, Matt Harbison <mharbison72 at gmail.com> wrote:
>>
>> On Wed, 09 Jan 2019 15:30:19 -0500, Augie Fackler <raf at durin42.com>  
>> wrote:
>>
>>>
>>>
>>>> On Dec 6, 2018, at 23:21, Matt Harbison <mharbison72 at gmail.com> wrote:
>>>>
>>>> On Wed, 05 Dec 2018 08:23:17 -0500, Yuya Nishihara <yuya at tcha.org>  
>>>> wrote:
>>>>
>>>>> On Tue, 4 Dec 2018 10:06:24 -0500, Augie Fackler wrote:
>>>>>>
>>>>>> So, options to move forward:
>>>>>> 1) blacken everything (controversial for good reasons)
>>>>>> 2) try black only on a subset
>>>>>> 3) explore yapf
>>>>>> 4) Give up and keep manually formatting files (I'd rather not do  
>>>>>> this, but I understand if it's where we end up)
>>>>>
>>>>> My vote: 3 > 4 > 2 > 1
>>>>>
>>>>> I'm not super enthusiastic about 100%-machine-forced formatting. I  
>>>>> like
>>>>> consistency level provided by e.g. astyle command. clang-format is  
>>>>> pretty
>>>>> good IMHO, but the black seems to sacrifice the code readability.
>>>>
>>>> +1.
>>>>
>>>> That said, I got used to longnamesthataresmooshedtogether, so I can  
>>>> probably adjust to anything after awhile.
>>>
>>> I think I'd still prefer black overall (yapf is less opinionated and  
>>> requires me to think more), but here's a yapf RFC:  
>>> https://phab.mercurial-scm.org/D5539
>>>
>>> This would at least help _most_ cases of line-too-long, which I think  
>>> would be good. What do people think?
>>
>> I think there's less that I dislike with yapf, but I'm not adamant  
>> about it.
>
> Should I pursue fixing any bugs in yapf, or is this a lukewarm "I'd  
> rather we not bother" sort of feeling?

It's lukewarm.  I probably focus too much on what I don't like, knowing it  
can't be fixed.  But in fairness, I think it made some things better,  
which means human formatting isn't great either.

I'm not sure how much time it would require to pursue fixing yapf.  If  
it's not a lot, maybe it's a reasonable middle ground between nothing and  
black?  I like the idea in theory, but don't look forward to retraining my  
mind to read some of these things.  But don't let me dump all over it-  
like I said, I've never seriously tried to use one.  Maybe it won't take  
that long to get used to.


More information about the Mercurial-devel mailing list