[Cubicweb] a script to save you time during development/project cleaning: autocommit the fixes of autopep8 so you don't have to do it by hand

Laurent Peuch cortex at worlddomination.be
Thu May 2 12:04:39 CEST 2019


Hello everyone,

Nico asked me to also to send those emails on this mailing list to
describe the tools I've been creating to help the work on CW
(especially migration). Here is the first one :)

During development of cubicweb and logilab related project we often
face ourselves with the need to conform with pep8 guidelines, either
because we prefer it, want it or to please the flake8/pep8 god (and
remove the red warning everywhere in your editor.) This task is often
done by hand (or with autopep8 on the file your are on right now)and
can take quite some time, a not very interesting time that would be
better put on funnier things.

To win this time and do much more interesting things I've recreate a
long lost script by Denis that wraps autopep8 and do the job for you:
you launch it into a project, is fix everything and do a commit per
error categories fixes by pep8 (or only on commit if you prefer.) The
usage is very simple:

    pip install --user autocommitautopep8

    # anywhere in a hg/git repository
    autocommitautopep8

(be aware that this can take quite some time if you have a lot of
files.)

If you want only one commit do:

    autocommitautopep8 -s
    # or
    autocommitautopep8 --single-commit

And you can also specify a path to a git/hg repository using
-p/--path:

    autocommitautopep8 --path path/to/my/project

The code is here: https://github.com/Psycojoker/autocommitautopep8
Feel free to send patch/contributions/open... tickets here of there :)

As an anecdote I've launched it on all the projects I could find on
https://www.cubicweb.org/project/ and ended up with ... 2300 patches ^^'
I haven't send them here since it would have been madness and totally
pointless to have you review 2300 patches. I think that we should
simply apply this script to the whole code base one day (once we are
happy with it) and don't think about it anymore and use mercurial
format-source extension if we need it https://octobus.net/blog/2018-12-03-mercurial-format-source-0.2.0.html
But we have first to agree on that which might happen one day :)

Cheers <3

-- 

Laurent Peuch -- Bram



More information about the Cubicweb mailing list