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: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
changes/92/2241792/6
Peter Wen 5 years ago committed by LUCI CQ
parent 23bd174fea
commit 2ba05f1672

@ -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:

Loading…
Cancel
Save