Auto-formatting code with black - object now if you have a strong opinion

Boris FELD boris.feld at octobus.net
Fri Nov 30 07:25:04 EST 2018


I think using automatic formatting is a great idea and we should move
forward with this plan. Black seems a good option. I share other's
concerns about the formatting of import. I also wonder if this also
applies to list and dict formatting that we tend to express with one
value per line for clarity.

When doing this change, we should leverage all the available tooling
around Mercurial + source formatting. This means using `hg fix` to help
with the formatting of in-progress patches, but also the `format-source`
extensions to remove merge conflict introduced by formatting. `fix` and
`format-source` are complementary.

Using tools like format source in the Mercurial project is important for
multiple reasons:

First, it is useful, formatting introduces pervasive changes that will
conflict with all in progress contribution. And such conflict will
happen every-time we adjust the formatting. `format-source` removes
these conflict. Making contributors life easier.

Second, we have been displaying the format-source extensions in a couple
of conferences and it received a very warm welcome. Multiple people
pointing out this is the kind of tooling giving Mercurial a significant
edge over other VCS. Using it for Mercurial will help to polish it and
make sure source-code formatting becomes a first class citizen in Mercurial.


Overall, `hg fix` and `hg format-source` handle two facets of the same
issue and should be merged (or at least share a large part of code and
configuration). I know that Martijn Pieters and Danny Hooper made some
plan in that direction at the last sprint.

On 27/11/2018 16:52, Augie Fackler wrote:
> In https://phab.mercurial-scm.org/D5064 we're talking about using the `black` formatter from Ɓukasz Langa on hg. This will imply a few style changes to our codebase, notably:
>
>  * We'll use " everywhere instead of '
>  * Import formatting will change a bit
>  * We'll have two blank lines between top-level items in a module
>
> Everything else is, as best I can tell, a minor style change of sorts. My preference at this point is to land the change and just give our formatting entirely to black, even if at the edges I disagree with some of black's decisions. Does anyone have a strong opinion _against_ using black to format our code?
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list