Support formatting python3 scripts (reland)

Original CL: https://crrev.com/c/2241792

Fix Windows use case by calling yapf directly without going through
yapf.bat.

Bug: 1062053,1095581
Change-Id: I31a9f09cba655d6ac1b4da9874a24a41aa007b17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2249606
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index fe92b2c..98ab9d7 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -4894,8 +4894,6 @@
   if python_diff_files and not py_explicitly_disabled:
     depot_tools_path = os.path.dirname(os.path.abspath(__file__))
     yapf_tool = os.path.join(depot_tools_path, 'yapf')
-    if sys.platform.startswith('win'):
-      yapf_tool += '.bat'
 
     # Used for caching.
     yapf_configs = {}
@@ -4931,7 +4929,13 @@
       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: