[Python-Dev] Code formatter bot (original) (raw)

Andrew Barnert abarnert at yahoo.com
Wed Jan 20 12:58:12 EST 2016


On Jan 20, 2016, at 00:35, Ben Finney <ben+python at benfinney.id.au> wrote:

francismb <francismb at email.de> writes:

what's your opinion about a code-formatter bot for cpython. What is the proposal? The opinions will surely depend on:

... plus:

But one comment on Ben's comment:

* If on the other hand you propose to enforce only those rules which are strict enough to be applied automatically (e.g. “don't mix spaces and TABs”, “encode source using UTF-8 only”) then that's best done by editor plug-ins like EditorConfig[0].

In my experience (although mostly with projects with a lot fewer contributors than CPython...), it can be helpful to have both suggested editor plugins that do the auto formatting on the dev's computer, and VCS-triggered checkers that ensure the formatting was correct. That catches those occasional cases where you do a quick "trivial" edit in nano instead of your usual editor and then forget you did so and try to check in), without the nasty side-effects you mention later (like committing code you haven't seen).

(Of course writing plugins that understand "legacy code" in the exact same way as the commit filter can be tricky, but in that case, it's better to know that one or the other isn't working as intended--both so a human can decide, and so people can see the bug in the plugin or filter--than to automatically make changes that weren't wanted.)



More information about the Python-Dev mailing list