summaryrefslogtreecommitdiff
path: root/chromium/styleguide/python
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-16 11:45:35 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-17 08:59:23 +0000
commit552906b0f222c5d5dd11b9fd73829d510980461a (patch)
tree3a11e6ed0538a81dd83b20cf3a4783e297f26d91 /chromium/styleguide/python
parent1b05827804eaf047779b597718c03e7d38344261 (diff)
downloadqtwebengine-chromium-552906b0f222c5d5dd11b9fd73829d510980461a.tar.gz
BASELINE: Update Chromium to 83.0.4103.122
Change-Id: Ie3a82f5bb0076eec2a7c6a6162326b4301ee291e Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/styleguide/python')
-rw-r--r--chromium/styleguide/python/OWNERS1
-rw-r--r--chromium/styleguide/python/blink-python.md2
-rw-r--r--chromium/styleguide/python/python.md48
3 files changed, 30 insertions, 21 deletions
diff --git a/chromium/styleguide/python/OWNERS b/chromium/styleguide/python/OWNERS
index bf7129f19f0..3dd24727e2b 100644
--- a/chromium/styleguide/python/OWNERS
+++ b/chromium/styleguide/python/OWNERS
@@ -1,6 +1,5 @@
agrieve@chromium.org
dpranke@chromium.org
-estevenson@chromium.org
jbudorick@chromium.org
wnwen@chromium.org
diff --git a/chromium/styleguide/python/blink-python.md b/chromium/styleguide/python/blink-python.md
index f37dd42e7aa..931c4bc2caf 100644
--- a/chromium/styleguide/python/blink-python.md
+++ b/chromium/styleguide/python/blink-python.md
@@ -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`
diff --git a/chromium/styleguide/python/python.md b/chromium/styleguide/python/python.md
index 12f2c52aaba..f56902dbe85 100644
--- a/chromium/styleguide/python/python.md
+++ b/chromium/styleguide/python/python.md
@@ -1,34 +1,38 @@
-# 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
@@ -49,7 +53,7 @@ Directories can opt into enforcing auto-formatting by adding a `.style.yapf`
file with the following contents:
```
[style]
-based_on_style = chromium
+based_on_style = pep8
```
Entire files can be formatted (rather than just touched lines) via:
@@ -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`.