Commit fa40bfa3 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

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/+/1987006Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
parent cd1331ea
[style] [style]
based_on_style = chromium based_on_style = pep8
indent_width = 2
column_limit = 80
...@@ -5262,10 +5262,6 @@ def CMDformat(parser, args): ...@@ -5262,10 +5262,6 @@ def CMDformat(parser, args):
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
yapf_tool += '.bat' yapf_tool += '.bat'
# If we couldn't find a yapf file we'll default to the chromium style
# specified in depot_tools.
chromium_default_yapf_style = os.path.join(depot_tools_path,
YAPF_CONFIG_FILENAME)
# Used for caching. # Used for caching.
yapf_configs = {} yapf_configs = {}
for f in python_diff_files: for f in python_diff_files:
...@@ -5295,11 +5291,12 @@ def CMDformat(parser, args): ...@@ -5295,11 +5291,12 @@ def CMDformat(parser, args):
yapfignore_patterns) yapfignore_patterns)
for f in filtered_py_files: for f in filtered_py_files:
yapf_config = _FindYapfConfigFile(f, yapf_configs, top_dir) yapf_style = _FindYapfConfigFile(f, yapf_configs, top_dir)
if yapf_config is None: # Default to pep8 if not .style.yapf is found.
yapf_config = chromium_default_yapf_style if not yapf_style:
yapf_style = 'pep8'
cmd = [yapf_tool, '--style', yapf_config, f] cmd = [yapf_tool, '--style', yapf_style, f]
has_formattable_lines = False has_formattable_lines = False
if not opts.full: if not opts.full:
......
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