Skip to content

Commit fa40bfa

Browse files
Andrew GrieveCommit Bot
Andrew Grieve
authored and
Commit Bot
committed
Update "git cl format --python" to default to PEP-8
This matches the recent change Chromium's Python style guide. This also changes the .style.yapf in depot_tools to be explicit about the style used in this repo. Bug: 846432 Change-Id: I4947a90aec1739a9a86ffc9bfc5eacc1182dc186 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1987006 Reviewed-by: Robbie Iannucci <[email protected]> Commit-Queue: Andrew Grieve <[email protected]>
1 parent cd1331e commit fa40bfa

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

.style.yapf

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
[style]
2-
based_on_style = chromium
2+
based_on_style = pep8
3+
indent_width = 2
4+
column_limit = 80

git_cl.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -5262,10 +5262,6 @@ def CMDformat(parser, args):
52625262
if sys.platform.startswith('win'):
52635263
yapf_tool += '.bat'
52645264

5265-
# If we couldn't find a yapf file we'll default to the chromium style
5266-
# specified in depot_tools.
5267-
chromium_default_yapf_style = os.path.join(depot_tools_path,
5268-
YAPF_CONFIG_FILENAME)
52695265
# Used for caching.
52705266
yapf_configs = {}
52715267
for f in python_diff_files:
@@ -5295,11 +5291,12 @@ def CMDformat(parser, args):
52955291
yapfignore_patterns)
52965292

52975293
for f in filtered_py_files:
5298-
yapf_config = _FindYapfConfigFile(f, yapf_configs, top_dir)
5299-
if yapf_config is None:
5300-
yapf_config = chromium_default_yapf_style
5294+
yapf_style = _FindYapfConfigFile(f, yapf_configs, top_dir)
5295+
# Default to pep8 if not .style.yapf is found.
5296+
if not yapf_style:
5297+
yapf_style = 'pep8'
53015298

5302-
cmd = [yapf_tool, '--style', yapf_config, f]
5299+
cmd = [yapf_tool, '--style', yapf_style, f]
53035300

53045301
has_formattable_lines = False
53055302
if not opts.full:

0 commit comments

Comments
 (0)