Code Formatter Questions

Matt Wheeler m at funkyhat.org
Mon Mar 29 06:15:07 EDT 2021



> On 29 Mar 2021, at 04:45, Cameron Simpson <cs at cskk.id.au> wrote:
> 
> yapf has many tunings. Worth a look. It is my preferred formatter. By 
> comparison, black is both opinionated and has basicly no tuning, 
> something I greatly dislike.

This is not a mark or a vote against yapf (I’ve never used it), but I think Black’s lack of tuning is one of its greatest strengths.
I’ve found in 2 teams in 2 very different companies, implementing `black —check` in CI made the code review process significantly more pleasant for both reviewers and review-ees.

I don’t know for sure, but I think the opinionated nature of Black was what enabled us to actually get the implementation off the ground (in company 1 several other attempts to get a code formatter running across the board had failed over the years). We completely sidestepped any discussion about which features of $tool were going to be enabled or not.

Black has a couple of minor opinions that I disagree with, but the net benefit of having everyone producing code in the same style (and importantly no-one having to *think* about the style while coding) vastly outweighs any annoyance I might have with those minor points, to the extent that I can’t actually remember what those disagreements are.


More information about the Python-list mailing list