Commit 32bc5e0d authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Python Style: Remove PEP-8 exceptions for indent & naming

As per discussion: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/RcJgJdkNIdg/discussion

Bug: 846432
Change-Id: I0d1abb42c79278d5edf03091a47fce03d5897c25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984356
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728275}
parent 9213e232
......@@ -14,5 +14,3 @@ style recommendation is likely to change._
## Differences from Chromium style
* Line length limit is 132
* Uses four-space indent
* Uses `function_name`, `method_name` rather than `FunctionName`, `MethodName`
# Chromium Python style guide
# Chromium Python Style Guide
_For other languages, please see the [Chromium style
guides](https://chromium.googlesource.com/chromium/src/+/master/styleguide/styleguide.md)._
Chromium follows [PEP-8](https://www.python.org/dev/peps/pep-0008/) unless an
exception is listed below.
Chromium follows [PEP-8](https://www.python.org/dev/peps/pep-0008/).
See also the [Chromium OS Python Style
Guidelines](https://sites.google.com/a/chromium.org/dev/chromium-os/python-style-guidelines).
It is also encouraged to follow advice from
[Google's Python Style Guide](https://google.github.io/styleguide/pyguide.html),
which is a superset of PEP-8.
You can propose changes to this style guide by sending an email to
`python@chromium.org`. Ideally, the list will arrive at some consensus and you
can request review for a change to this file. If there's no consensus,
[`//styleguide/python/OWNERS`](https://chromium.googlesource.com/chromium/src/+/master/styleguide/python/OWNERS)
get to decide.
Blink code in `third_party/blink` uses [Blink style](blink-python.md).
See also:
* [Chromium OS Python Style Guide](https://sites.google.com/a/chromium.org/dev/chromium-os/python-style-guidelines)
* [Blink Python Style Guide](blink-python.md)
[TOC]
## Differences from PEP-8
## Our Previous Python Style
Chromium used to differ from PEP-8 in the following ways:
* Use two-space indentation instead of four-space indentation.
* Use `CamelCase()` method and function names instead of `unix_hacker_style()`
names.
* 80 character line limits rather than 79.
(The rationale for these is mostly legacy: the code was originally written
following Google's internal style guideline, the cost of updating all of the
code to PEP-8 compliance was not small, and consistency was seen to be a
greater virtue than compliance.)
New scripts should not follow these deviations, but they should be followed when
making changes to files that follow them.
## Making Style Guide Changes
You can propose changes to this style guide by sending an email to
`python@chromium.org`. Ideally, the list will arrive at some consensus and you
can request review for a change to this file. If there's no consensus,
[`//styleguide/python/OWNERS`](https://chromium.googlesource.com/chromium/src/+/master/styleguide/python/OWNERS)
get to decide.
## Tools
......@@ -57,6 +61,14 @@ Entire files can be formatted (rather than just touched lines) via:
git cl format --python --full
```
YAPF has gotchas. You should review its changes before submitting. Notably:
* It does not re-wrap comments.
* It won't insert characters in order wrap lines. You might need to add ()s
yourself in order to have to wrap long lines for you.
* It formats lists differently depending on whether or not they end with a
trailing comma.
#### Bugs
* Are tracked here: https://github.com/google/yapf/issues.
* For Chromium-specific bugs, please discuss on `python@chromium.org`.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment