Interesting coincidence :-)

We (at Google) are just on the verge of releasing an open-source tool for auto-formatting of Python code. It should be posted to Github within the next few days or weeks, under a permissive license (Apache 2.0 or something similar).

The tool works like gofmt and clang-format (the C++/JS version provided as part of the Clang toolchain) - it only acts on whitespace and performs re-formatting of code (PEP-8 oriented for Python but it's configurable). It does not rename variables/classes/functions to conform to any particular style. The algorithm is based on clang-format, and lib2to3 is used for the parsing side - so it's very solid. We use it on Python 2 code internally, but Python 3 support is also planned and should be easy.

We intend to keep actively developing the tool in the open and will be happy to accept test cases, fixes and patches in general.

So stay tuned!

P.S. I'm also against such a tool being a part of the Python distribution, at least in the near term. A tool/library has to first prove itself outside of core for a while, and only when/if it proves to be widely used and stable, an incorporation into core should be considered. The stdlib is big as it is, and any additional code is a burden on all core developers. Incorporation into the stdlib also imposes a very slow pace of development/release on said library/tool, and hence should only be considered when it's been extremely stable for a while.

Eli



On Tue, Mar 17, 2015 at 7:17 PM, Nicholas Chammas <nicholas.chammas@gmail.com> wrote:
First class means it's like a language feature. Actually, in my case I am using "first-class" and "included with the language" synonymously. Not sure if that's appropriate terminology, but that's what I mean.

To explain by rough analogy, Twisted is to asyncio what autopep8 would be to a first-class auto-styler. (I say "rough" because I understand that Twisted is not supposed to be replaced entirely by asyncio, but I hope my point is clear.)

Nick

On Tue, Mar 17, 2015 at 9:58 PM Ethan Furman <ethan@stoneleaf.us> wrote:
On 03/17/2015 06:54 PM, Nicholas Chammas wrote:

> I am not proposing putting |autopep8| in the standard library. I am proposing that an auto-styler be included with
> Python as a first-class utility. The emphasis here is on /included/ and /first-class/.

Perhaps you could explain what you mean by a /first-class/ utility?

--
~Ethan~

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/