tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 4cd9582b8ef944c596ed89044e6770ccd62464aa
parent fa8e7abb4ad360508a419ae5511d237694dcecff
Author: Alex Hochheiden <ahochheiden@mozilla.com>
Date:   Wed, 10 Dec 2025 06:03:26 +0000

Bug 2003412 - Fix PLW1510 warnings: Add explicit check argument to subprocess.run r=emilio,perftest-reviewers,mozperftest-reviewers,media-playback-reviewers,android-reviewers,jdescottes,padenot,sparky,calu

https://docs.astral.sh/ruff/rules/subprocess-run-without-check/

Differential Revision: https://phabricator.services.mozilla.com/D274699

Diffstat:
Mdom/media/test/reftest/gen_combos.py | 2+-
Mmobile/android/android-components/automation/publish_to_maven_local_if_modified.py | 3+--
Mpython/mach/mach/site.py | 11++++++-----
Mpython/mach/mach/test/test_site_activation.py | 2++
Mpython/mozboot/mozboot/osx.py | 1+
Mpython/mozbuild/mozbuild/backend/mach_commands.py | 10++++++++--
Mpython/mozbuild/mozbuild/doctor.py | 1+
Mpython/mozbuild/mozbuild/mach_commands.py | 5++++-
Mpython/mozbuild/mozbuild/repackaging/flatpak.py | 2+-
Mpython/mozperftest/mozperftest/script.py | 5++++-
Mpython/mozperftest/mozperftest/system/setups.py | 2+-
Msecurity/manager/tools/pypkcs12.py | 1+
Mtesting/mozharness/scripts/openh264_build.py | 8++++++--
Mtesting/raptor/browsertime/support-scripts/network_bench.py | 2++
Mtesting/raptor/raptor/perftest.py | 2+-
Mtoolkit/components/extensions/webidl-api/GenerateWebIDLBindings.py | 1+
Mtools/lint/python/l10n_lint.py | 9++++++---
Mtools/signing/macos/mach_commands.py | 2+-
18 files changed, 48 insertions(+), 21 deletions(-)

diff --git a/dom/media/test/reftest/gen_combos.py b/dom/media/test/reftest/gen_combos.py @@ -236,7 +236,7 @@ def run_cmd(args): if "-vv" not in ARGS: dest = subprocess.DEVNULL try: - subprocess.run(args, stderr=dest) + subprocess.run(args, check=False, stderr=dest) except FileNotFoundError: print("FileNotFoundError, is ffmpeg not in your PATH?") raise diff --git a/mobile/android/android-components/automation/publish_to_maven_local_if_modified.py b/mobile/android/android-components/automation/publish_to_maven_local_if_modified.py @@ -24,8 +24,7 @@ def fatal_err(msg): def run_cmd_checked(*args, **kwargs): """Run a command, throwing an exception if it exits with non-zero status.""" - kwargs["check"] = True - return subprocess.run(*args, **kwargs) + return subprocess.run(*args, check=True, **kwargs) def find_project_root(): diff --git a/python/mach/mach/site.py b/python/mach/mach/site.py @@ -764,10 +764,10 @@ class CommandSiteManager: check_errors: str = "\n" # save output when check fails check_result = subprocess.run( pip_command(python_executable=self.python_path, subcommand="check"), + check=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, - check=False, ) if not check_result.returncode: @@ -826,10 +826,10 @@ class CommandSiteManager: check_result = subprocess.run( pip_command(python_executable=self.python_path, subcommand="check"), + check=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, - check=False, ) if check_result.returncode: @@ -1086,6 +1086,7 @@ class PythonVirtualenv: subcommand="install", args=pip_install_args, ), + check=kwargs.pop("check", True), **kwargs, ) except subprocess.CalledProcessError as cpe: @@ -1383,9 +1384,9 @@ def _assert_pip_check(pthfile_lines, virtualenv_name, requirements): # changes recently). process = subprocess.run( [sys.executable, "-m", "venv", "--without-pip", check_env_path], + check=False, capture_output=True, encoding="UTF-8", - check=False, ) if process.returncode != 0: @@ -1430,10 +1431,10 @@ def _assert_pip_check(pthfile_lines, virtualenv_name, requirements): check_result = subprocess.run( pip + ["check"], + check=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, - check=False, ) if check_result.returncode: subprocess.check_call(pip + ["list", "-v"], stdout=sys.stderr) @@ -1496,9 +1497,9 @@ def _create_venv_with_pthfile( process = subprocess.run( [sys.executable, "-m", "venv", "--without-pip", virtualenv_root], + check=False, capture_output=True, encoding="UTF-8", - check=False, ) if process.returncode != 0: diff --git a/python/mach/mach/test/test_site_activation.py b/python/mach/mach/test/test_site_activation.py @@ -357,6 +357,7 @@ def _run_activation_script( source: str, site_name: str, invoking_python: str, + check: bool = False, **kwargs, ) -> CompletedProcess: return subprocess.run( @@ -364,6 +365,7 @@ def _run_activation_script( invoking_python, str(Path(__file__).parent / "script_site_activation.py"), ], + check=check, stdout=subprocess.PIPE, text=True, env={ diff --git a/python/mozboot/mozboot/osx.py b/python/mozboot/mozboot/osx.py @@ -108,6 +108,7 @@ def ensure_command_line_tools(): # (via `xcode-select --install`). proc = subprocess.run( ["xcode-select", "--print-path"], + check=False, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, ) diff --git a/python/mozbuild/mozbuild/backend/mach_commands.py b/python/mozbuild/mozbuild/backend/mach_commands.py @@ -49,7 +49,9 @@ def run(command_context, ide, no_interactive, args): if ide == "vscode": result = subprocess.run( - [sys.executable, "mach", "configure"], cwd=command_context.topsrcdir + [sys.executable, "mach", "configure"], + check=False, + cwd=command_context.topsrcdir, ) if result.returncode: return result.returncode @@ -59,6 +61,7 @@ def run(command_context, ide, no_interactive, args): # export target, because we can't do anything better. result = subprocess.run( [sys.executable, "mach", "build", "pre-export", "export", "pre-compile"], + check=False, cwd=command_context.topsrcdir, ) if result.returncode: @@ -68,7 +71,9 @@ def run(command_context, ide, no_interactive, args): # probably more correct but it's also nice having a single target to get a fully # built and indexed project (gives a easy target to use before go out to lunch). result = subprocess.run( - [sys.executable, "mach", "build"], cwd=command_context.topsrcdir + [sys.executable, "mach", "build"], + check=False, + cwd=command_context.topsrcdir, ) if result.returncode: return result.returncode @@ -86,6 +91,7 @@ def run(command_context, ide, no_interactive, args): # Generate or refresh the IDE backend. result = subprocess.run( [sys.executable, "mach", "build-backend", "-b", backend], + check=False, cwd=command_context.topsrcdir, ) if result.returncode: diff --git a/python/mozbuild/mozbuild/doctor.py b/python/mozbuild/mozbuild/doctor.py @@ -140,6 +140,7 @@ def ssh(**kwargs) -> DoctorCheck: # the successful code path, since we don't specify a `pash` command. proc = subprocess.run( ["ssh", "hg.mozilla.org"], + check=False, encoding="utf-8", capture_output=True, ) diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py @@ -426,6 +426,7 @@ def cargo_vet(command_context, arguments, stdout=None, env=os.environ): try: res = subprocess.run( [cargo, "vet"] + arguments, + check=False, cwd=cargo_vet_dir, stdout=stdout, env=env, @@ -572,7 +573,9 @@ def clobber(command_context, what, full=False): ret = subprocess.call(cmd, cwd=topsrcdir) elif conditions.is_git(command_context) or conditions.is_jj(command_context): cmd = ["git", "clean", "-d", "-f", "-x", "*.py[cdo]", "*/__pycache__/*"] - result = subprocess.run(cmd, cwd=topsrcdir, stderr=subprocess.DEVNULL) + result = subprocess.run( + cmd, check=False, cwd=topsrcdir, stderr=subprocess.DEVNULL + ) # We assume the `jj` repo is a colocated `git` repo, if not, fall back to a pure python approach if conditions.is_jj(command_context) and result.returncode != 0: _pure_python_clean(topsrcdir) diff --git a/python/mozbuild/mozbuild/repackaging/flatpak.py b/python/mozbuild/mozbuild/repackaging/flatpak.py @@ -35,7 +35,7 @@ def run_command(log, *args, **kwargs): {"command": shlex.join(args[0]), "cwd": str(kwargs.get("cwd", os.getcwd()))}, "Running: {command} (in {cwd})", ) - return subprocess.run(*args, **kwargs) + return subprocess.run(*args, check=True, **kwargs) def _inject_flatpak_distribution_ini(log, target): diff --git a/python/mozperftest/mozperftest/script.py b/python/mozperftest/mozperftest/script.py @@ -151,7 +151,9 @@ class ScriptInfo(defaultdict): const builtins = Object.getOwnPropertyNames(globalThis); console.log(JSON.stringify(builtins)); """ - result = subprocess.run(["node", "-e", js], capture_output=True, text=True) + result = subprocess.run( + ["node", "-e", js], check=True, capture_output=True, text=True + ) return set(json.loads(result.stdout)) def _classify_globals(self): @@ -295,6 +297,7 @@ class ScriptInfo(defaultdict): process = subprocess.run( ["node", "-e", js_code], + check=False, capture_output=True, text=True, ) diff --git a/python/mozperftest/mozperftest/system/setups.py b/python/mozperftest/mozperftest/system/setups.py @@ -75,7 +75,7 @@ class DesktopVersionProducer(BaseVersionProducer): elif "linux" in platform.system().lower(): command = [binary, "--version"] proc = subprocess.run( - command, timeout=10, capture_output=True, text=True + command, check=True, timeout=10, capture_output=True, text=True ) bmeta = proc.stdout.split("\n") diff --git a/security/manager/tools/pypkcs12.py b/security/manager/tools/pypkcs12.py @@ -55,6 +55,7 @@ def runUtil(util, args): env[pathvar] = app_path proc = subprocess.run( [util] + args, + check=False, env=env, text=True, ) diff --git a/testing/mozharness/scripts/openh264_build.py b/testing/mozharness/scripts/openh264_build.py @@ -248,8 +248,12 @@ class OpenH264Build(TransferMixin, VCSScript, TooltoolMixin): def _git_checkout(self, repo, repo_dir, rev): try: - subprocess.run(["git", "clone", "-q", "--no-checkout", repo, repo_dir]) - subprocess.run(["git", "checkout", "-q", "-f", f"{rev}^0"], cwd=repo_dir) + subprocess.run( + ["git", "clone", "-q", "--no-checkout", repo, repo_dir], check=False + ) + subprocess.run( + ["git", "checkout", "-q", "-f", f"{rev}^0"], check=False, cwd=repo_dir + ) except Exception: self.rmtree(repo_dir) raise diff --git a/testing/raptor/browsertime/support-scripts/network_bench.py b/testing/raptor/browsertime/support-scripts/network_bench.py @@ -62,6 +62,7 @@ class NetworkBench(BasePythonSupport): try: result = subprocess.run( ["caddy", "version"], + check=False, capture_output=True, text=True, ) @@ -256,6 +257,7 @@ class NetworkBench(BasePythonSupport): try: result = subprocess.run( ["sudo", "tc", "-help"], + check=False, capture_output=True, text=True, ) diff --git a/testing/raptor/raptor/perftest.py b/testing/raptor/raptor/perftest.py @@ -876,7 +876,7 @@ class PerftestDesktop(Perftest): elif "linux" in self.config["platform"]: command = [self.config["binary"], "--version"] proc = subprocess.run( - command, timeout=10, capture_output=True, text=True + command, check=False, timeout=10, capture_output=True, text=True ) bmeta = proc.stdout.split("\n") diff --git a/toolkit/components/extensions/webidl-api/GenerateWebIDLBindings.py b/toolkit/components/extensions/webidl-api/GenerateWebIDLBindings.py @@ -130,6 +130,7 @@ def run_diff( right_file.flush() diff_output = subprocess.run( [diff_cmd, "-u", left_file.name, right_file.name], + check=False, capture_output=True, ).stdout.decode("utf-8") diff --git a/tools/lint/python/l10n_lint.py b/tools/lint/python/l10n_lint.py @@ -124,14 +124,17 @@ def source_repo_setup(**lint_args): os.environ.pop("GIT_INDEX_FILE") kwargs = { - "check": False, "stdout": subprocess.PIPE, "stderr": subprocess.STDOUT, } if os.path.exists(gs): - proc = subprocess.run([git, "pull", L10N_SOURCE_REPO], cwd=gs, **kwargs) + proc = subprocess.run( + [git, "pull", L10N_SOURCE_REPO], check=False, cwd=gs, **kwargs + ) else: - proc = subprocess.run([git, "clone", L10N_SOURCE_REPO, gs], **kwargs) + proc = subprocess.run( + [git, "clone", L10N_SOURCE_REPO, gs], check=False, **kwargs + ) if proc.returncode != 0: lint_args["log"].error( diff --git a/tools/signing/macos/mach_commands.py b/tools/signing/macos/mach_commands.py @@ -550,7 +550,7 @@ def run(ctx, cmd, **kwargs): cmd_as_str = " ".join(cmd) ctx.log(logging.DEBUG, "macos-sign", {"cmd": cmd_as_str}, "[{cmd}]") try: - subprocess.run(cmd, **kwargs) + subprocess.run(cmd, check=True, **kwargs) except subprocess.CalledProcessError as e: ctx.log( logging.ERROR,