3 ms·
YAPF – A formatter for Python files
- strunz 12y agoInteresting, but on a quick test it looks like it changes UNIX-style line endings (LF) to Windows (CRLF).
- eliben 12y agoThis shouldn't happen - please report an issue
- pmags 12y agoLook'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 https://www.python.org/dev/peps/pep-0008/#indentation)
- geoelectric 12y agoWithout 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.
- ketralnis 12y agoThat is apparently the "google style" https://github.com/google/yapf/blob/master/yapf/yapflib/style.py#L114 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.
- geoelectric 12y agoI thought about that, but https://google-styleguide.googlecode.com/svn/trunk/pyguide.html 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.
- eliben 12y agoyapf 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.
- geoelectric 12y agoI think you've conflated Chromium style with Google style. https://www.chromium.org/chromium-os/python-style-guidelines https://www.chromium.org/chromium-os/python-style-guidelines ...is 2 spaces. http://google-styleguide.googlecode.com/svn/trunk/pyguide.html 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 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.