For other languages, please see the Chromium style guides.
Chromium follows PEP-8.
It is also encouraged to follow advice from Google's Python Style Guide, which is a superset of PEP-8.
See also:
Chromium used to differ from PEP-8 in the following ways:
CamelCase()
method and function names instead of unix_hacker_style()
names.New scripts should not follow these deviations, but they should be followed when making changes to files that follow them.
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
get to decide.
Depot tools contains a local copy of pylint, appropriately configured.
input_api.canned_checks.RunPylint()
.YAPF is the Python formatter used by:
git cl format --python
Directories can opt into enforcing auto-formatting by adding a .style.yapf
file with the following contents:
[style] based_on_style = pep8
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:
python@chromium.org
.