Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
YAPF – A formatter for Python files (github.com/google)
24 points by pdknsk on March 25, 2015 | hide | past | favorite | 8 comments


Look's interesting, but I hesitate to use a Python formatting tool whose own code runs counter to well accepted Python stylistic guidelines -- namely "Use 4 spaces per indentation level." (https://www.python.org/dev/peps/pep-0008/#indentation)


Without some examples from the author (or sinking time into installing/playing with it) it's pretty hard for me to tell what it's actually going to do with the code.

AutoPEP8 will generally intelligently pick between a standard hanging indent, a deep hanging indent, and an aligned indent. Does this not do so?

Edit: oh, I see. The author's code uses two spaces. Heh.


That is apparently the "google style" https://github.com/google/yapf/blob/master/yapf/yapflib/styl...

No option to change the line endings though, and it changes them all to Windows style.


I thought about that, but https://google-styleguide.googlecode.com/svn/trunk/pyguide.h... makes it pretty clear Google Style is 4 spaces.

It's under Python Style Rules | Indentation.


yapf is developed using an internal Google coding style. Please don't hold it against the project :-) Once you get used to the style, the code of yapf is very consistent in terms of style (it was formatted with yapf itself!) and should be easy to understand & work with.

It does support the PEP8 style out of the box, however.


I think you've conflated Chromium style with Google style.

https://www.chromium.org/chromium-os/python-style-guidelines

...is 2 spaces.

http://google-styleguide.googlecode.com/svn/trunk/pyguide.ht...

...is 4 spaces.

The other difference is naming style. Chromium uses CapWords instead of snake_case.

Edit:

https://news.ycombinator.com/item?id=1311799

^ that notes that you're referring to an internal style guide. Their external guide (which is the one I'd think I'd be following) is more PEP8-y.

You might consider renaming your "google" to "google-internal." But since Chromium appears to be the remaining big external-facing project using the old internal style, I'd suggest chromium vs. google vs. pep8. That would make more sense to the wider audience.


Interesting, but on a quick test it looks like it changes UNIX-style line endings (LF) to Windows (CRLF).


This shouldn't happen - please report an issue




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: