Le 25/09/2020 à 12:58, Han-Wen Nienhuys a écrit :



On Fri, Sep 25, 2020 at 9:36 AM Jonas Hahnfeld <hah...@hahnjo.de <mailto:hah...@hahnjo.de>> wrote:

    Am Freitag, den 25.09.2020, 09:31 +0200 schrieb Werner LEMBERG:
    > > What puzzles me a bit is the magnitude of changes from
    autopep8 - I
    > > thought this tool was run in August? Maybe I'm missing something;
    > > FWIW I used the invocation "autopep8 -ia --ignore=E402" as
    > > documented in CG.
    > >
    > > Thoughts, objections? Should I exclude running autopep8?
    >
    > I was told from a Python professional developer that the best
    tool for
    > formatting python code be `black`.  Running
    >
    >   black -l 78 ...
    >
    > gives indeed very nice formatting (not tested with lilypond stuff,
    > though).

    Hm, I thought we agreed on using autopep8 more than two months
    ago? I'm
    not very familiar with either tool but I'm against switching back and
    forth multiple times, that'll just cause churn in the code.


IIRC I think the option used was -aa (2x -a = aggressive.)

It's the opposite, actually. I ran autopep8 wit the default level of
aggressivity (no -a option), to be sure not to cause any regressions. Since
then the right fixes to exclude were found and we put something different
into the CG.

Black may be a good option. A good reason for using autopep8 back in the
time was its fix for invalid escape sequences. Which turned out to be
catastrophic. Since they are all fixed by now, and the interpreter will
emit warnings during bytecode compilation if any new are added, I don't
see any reason not to switch to Black. It's much less configurable, with
just good defaults, and has become a standard tool nowadays as far as I
can see (at least, it's in the PSF organisation on GitHub).

You could put this in a pyproject.toml file:

[tool.black]
line-length  =  78

Then the command would be just ``black .``

Thanks,
Jean

PS: After a quick look, I indeed prefer Black's reformatting over autopep8's.

Reply via email to