Commit 2ba05f16 authored by Peter Wen's avatar Peter Wen Committed by LUCI CQ

Support formatting python3 scripts

Use vpython or vpython3 to invoke yapf depending on the shebang line for
each file.

Bug: 1062053
Change-Id: I497fa48c08aa6052a2b06df7cc7f18e2154ab898
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2241792
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
parent 23bd174f
......@@ -4931,7 +4931,13 @@ def CMDformat(parser, args):
if not yapf_style:
yapf_style = 'pep8'
cmd = [yapf_tool, '--style', yapf_style, f]
with open(f, 'r') as py_f:
if 'python3' in py_f.readline():
vpython_script = 'vpython3'
else:
vpython_script = 'vpython'
cmd = [vpython_script, yapf_tool, '--style', yapf_style, f]
has_formattable_lines = False
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