formatting Python

78 views
Skip to first unread message

Thiago Farina

unread,
Feb 12, 2015, 8:46:42 PM2/12/15
to Chromium-dev
How do we format Python code? Is there a clang-format equivalent?

--
Thiago Farina

Dirk Pranke

unread,
Feb 12, 2015, 8:48:33 PM2/12/15
to Thiago Farina, Chromium-dev
There is third_party/WebKit/Tools/Scripts/format-webkitpy, which uses the Blink coding standard by default, but supports a '--chromium' flag as well.

-- Dirk

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Nico Weber

unread,
Feb 12, 2015, 10:02:38 PM2/12/15
to Dirk Pranke, Thiago Farina, Chromium-dev
…but in general, by hand, following the google python style guide. (Except in blink code, which uses regular pep 8).

Egor Pasko

unread,
Feb 13, 2015, 1:35:24 PM2/13/15
to Nico Weber, Dirk Pranke, Thiago Farina, Chromium-dev
On Fri, Feb 13, 2015 at 4:01 AM, Nico Weber <tha...@chromium.org> wrote:
…but in general, by hand, following the google python style guide. (Except in blink code, which uses regular pep 8).

And (of course) we deviated from the google style:

It is CamelCase methods and 2-space indentation essentially :)
 
On Thu, Feb 12, 2015 at 5:47 PM, Dirk Pranke <dpr...@chromium.org> wrote:
There is third_party/WebKit/Tools/Scripts/format-webkitpy, which uses the Blink coding standard by default, but supports a '--chromium' flag as well.

-- Dirk

On Thu, Feb 12, 2015 at 5:46 PM, Thiago Farina <tfa...@chromium.org> wrote:
How do we format Python code? Is there a clang-format equivalent?

--
Thiago Farina

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

Michael Moss

unread,
Feb 13, 2015, 1:43:35 PM2/13/15
to Egor Pasko, Nico Weber, Dirk Pranke, Thiago Farina, Chromium-dev
On Fri, Feb 13, 2015 at 10:34 AM, Egor Pasko <pa...@chromium.org> wrote:


On Fri, Feb 13, 2015 at 4:01 AM, Nico Weber <tha...@chromium.org> wrote:
…but in general, by hand, following the google python style guide. (Except in blink code, which uses regular pep 8).

And (of course) we deviated from the google style:

It is CamelCase methods and 2-space indentation essentially :)

That page needs updating. The Google naming convention (linked from that page) has recommended lower_with_under() function/method names for quite a while now.

Michael Moss

unread,
Feb 13, 2015, 1:52:03 PM2/13/15
to Egor Pasko, Nico Weber, Dirk Pranke, Thiago Farina, Chromium-dev
On Fri, Feb 13, 2015 at 10:42 AM, Michael Moss <mm...@chromium.org> wrote:


On Fri, Feb 13, 2015 at 10:34 AM, Egor Pasko <pa...@chromium.org> wrote:


On Fri, Feb 13, 2015 at 4:01 AM, Nico Weber <tha...@chromium.org> wrote:
…but in general, by hand, following the google python style guide. (Except in blink code, which uses regular pep 8).

And (of course) we deviated from the google style:

It is CamelCase methods and 2-space indentation essentially :)

That page needs updating. The Google naming convention (linked from that page) has recommended lower_with_under() function/method names for quite a while now.

Errr, that is to say, the internal style guide allows both CamelCase and lower_with_under, though I think CamelCase is meant mostly for consistency with legacy code.

Mike Frysinger

unread,
Feb 13, 2015, 3:43:26 PM2/13/15
to mm...@chromium.org, Egor Pasko, Nico Weber, Dirk Pranke, Thiago Farina, Chromium-dev
On Fri, Feb 13, 2015 at 1:51 PM, Michael Moss <mm...@chromium.org> wrote:
On Fri, Feb 13, 2015 at 10:42 AM, Michael Moss <mm...@chromium.org> wrote:
On Fri, Feb 13, 2015 at 10:34 AM, Egor Pasko <pa...@chromium.org> wrote:
On Fri, Feb 13, 2015 at 4:01 AM, Nico Weber <tha...@chromium.org> wrote:
…but in general, by hand, following the google python style guide. (Except in blink code, which uses regular pep 8).

And (of course) we deviated from the google style:

It is CamelCase methods and 2-space indentation essentially :)

That page needs updating. The Google naming convention (linked from that page) has recommended lower_with_under() function/method names for quite a while now.

Errr, that is to say, the internal style guide allows both CamelCase and lower_with_under, though I think CamelCase is meant mostly for consistency with legacy code.

i see no recommendations in the internal guide.  for function & method names, the two styles are given equal footing (which you're correct in that it is different from how it used to be where CapWords was the only permissible style).  there is a comment wrt module names, but we follow the style guide there (both internal & public).


i would note that this guide specifically covers Chromium OS.  i think trying to enforce the style guide on the Chromium code base is a lost cause ... every directory has its own tweaked style based entirely on what the author who started that subdir preferred.  in some places (like depot_tools) it's even worse as style easily deviates on a per-module basis.

tl;dr: i see nothing in the referenced dev.c.o guide that should be modified
-mike
Reply all
Reply to author
Forward
0 new messages