From 3d6dda8241fb6283f55966eb34d253f8fa44c927 Mon Sep 17 00:00:00 2001 From: Brian Ryner Date: Tue, 16 Jan 2024 18:25:09 +0000 Subject: [PATCH] Always run yapf with vpython3. The version we are using now does not run under python 2.7. Add an explicit python_version 3.8 to the inline spec so that we don't rely on vpython's default version. This is a no-op change when running with vpython3. We should run yapf under 3.11, but this needs additional testing and likely an update of zipp, so we'll do it separately. Change-Id: If1fccbe6b13c77a770bd1a8c9de0789d543ba890 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5198109 Auto-Submit: Brian Ryner Reviewed-by: Josip Sokcevic Commit-Queue: Josip Sokcevic --- git_cl.py | 8 +------- yapf | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/git_cl.py b/git_cl.py index edafad647..dda9cefbc 100755 --- a/git_cl.py +++ b/git_cl.py @@ -6286,13 +6286,7 @@ def _RunYapf(opts, paths, top_dir, upstream_commit): if not yapf_style: yapf_style = 'pep8' - with open(path, 'r') as py_f: - if 'python2' in py_f.readline(): - vpython_script = 'vpython' - else: - vpython_script = 'vpython3' - - cmd = [vpython_script, yapf_tool, '--style', yapf_style, path] + cmd = ['vpython3', yapf_tool, '--style', yapf_style, path] if not opts.full: ranges = line_diffs.get(path) diff --git a/yapf b/yapf index 40f272f5f..513548504 100755 --- a/yapf +++ b/yapf @@ -1,6 +1,7 @@ #!/usr/bin/env vpython3 # [VPYTHON:BEGIN] +# python_version: "3.8" # wheel: < # name: "infra/python/wheels/yapf-py3" # version: "version:0.40.2"