commit 7cc77b1400dcb4332477de795d3cf9b13d10b108 parent 9ce7ca3a62c6890ca556f664a5876177fb945d8e Author: Alex Hochheiden <ahochheiden@mozilla.com> Date: Wed, 10 Dec 2025 06:03:23 +0000 Bug 2003412 - Fix PLR1722 warnings: Use sys.exit() instead of exit()/quit() r=emilio,media-playback-reviewers,android-reviewers,padenot,tcampbell https://docs.astral.sh/ruff/rules/sys-exit-alias/ Differential Revision: https://phabricator.services.mozilla.com/D274690 Diffstat:
12 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/build/checksums.py b/build/checksums.py @@ -6,6 +6,7 @@ import hashlib import logging import os +import sys from optparse import OptionParser logger = logging.getLogger("checksums.py") @@ -145,7 +146,7 @@ def main(): for i in args: if not os.path.isdir(i): logger.error("%s is not a directory" % i) - exit(1) + sys.exit(1) process_files(args, options.outfile, options.digests) diff --git a/dom/media/test/reftest/gen_combos.py b/dom/media/test/reftest/gen_combos.py @@ -226,7 +226,7 @@ for args in todo: if "--write" not in ARGS: print("Use --write to write. Exiting...") - exit(0) + sys.exit(0) # - 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 @@ -19,7 +19,7 @@ from pathlib import Path def fatal_err(msg): print(f"\033[31mError: {msg}\033[0m") - exit(1) + sys.exit(1) def run_cmd_checked(*args, **kwargs): diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/conftest.py b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/conftest.py @@ -7,6 +7,7 @@ import logging import os import random import subprocess +import sys import time from pathlib import Path @@ -91,7 +92,7 @@ def fixture_load_branches(experiment_url): data = requests.get(f"{KLAATU_SERVER_URL}/experiment").json() except ConnectionRefusedError: logging.warn("No URL or experiment slug provided, exiting.") - exit() + sys.exit() else: for item in reversed(data): data = item @@ -144,7 +145,7 @@ def fixture_experiment_url(request, variables): data = requests.get(f"{KLAATU_SERVER_URL}/experiment").json() except requests.exceptions.ConnectionError: logging.error("No URL or experiment slug provided, exiting.") - exit() + sys.exit() else: for item in data: if isinstance(item, dict): diff --git a/mobile/android/fenix/tools/data_renewal_generate.py b/mobile/android/fenix/tools/data_renewal_generate.py @@ -116,7 +116,7 @@ with open(METRICS_FILENAME) as f: arg1 = sys.argv[1] except Exception: print("usage is to include argument of the form `100`") - quit() + sys.exit() # parse metrics.yaml to json write_header = True diff --git a/mobile/android/fenix/tools/data_renewal_request.py b/mobile/android/fenix/tools/data_renewal_request.py @@ -16,7 +16,7 @@ try: version = sys.argv[1] except Exception: print("usage is to include arguments of the form <version>") - quit() + sys.exit() expiry_filename = version + "_expiry_list.csv" filled_renewal_filename = version + "_filled_renewal_request.txt" diff --git a/mobile/android/focus-android/tools/data_renewal_generate.py b/mobile/android/focus-android/tools/data_renewal_generate.py @@ -118,7 +118,7 @@ with open(METRICS_FILENAME) as f: arg1 = sys.argv[1] except Exception: print("usage is to include argument of the form `100`") - quit() + sys.exit() # parse metrics.yaml to json write_header = True diff --git a/mobile/android/focus-android/tools/data_renewal_request.py b/mobile/android/focus-android/tools/data_renewal_request.py @@ -16,7 +16,7 @@ try: version = sys.argv[1] except Exception: print("usage is to include arguments of the form <version>") - quit() + sys.exit() expiry_filename = version + "_expiry_list.csv" filled_renewal_filename = version + "_filled_renewal_request.txt" diff --git a/python/mozboot/mozboot/rust.py b/python/mozboot/mozboot/rust.py @@ -171,12 +171,12 @@ if __name__ == "__main__": if version == RUSTUP_VERSION: print("We're up to date. Validating checksums.") make_checksums(version, validate=True) - exit() + sys.exit() if not update: print("Out of date. We use %s. Validating checksums." % RUSTUP_VERSION) make_checksums(RUSTUP_VERSION, validate=True) - exit() + sys.exit() print("Out of date. We use %s. Calculating checksums." % RUSTUP_VERSION) hashes = make_checksums(version) diff --git a/taskcluster/scripts/are_dependencies_completed.py b/taskcluster/scripts/are_dependencies_completed.py @@ -6,6 +6,7 @@ import argparse import os +import sys import taskcluster @@ -52,7 +53,7 @@ def main(): result = parser.parse_args() check_all_dependencies_are_completed(result.current_task_id) print("All dependencies are completed. Reporting a green task!") - exit(0) + sys.exit(0) if __name__ == "__main__": diff --git a/testing/mozharness/scripts/android_wrench.py b/testing/mozharness/scripts/android_wrench.py @@ -279,7 +279,7 @@ class AndroidWrench(TestingMixin, BaseScript, MozbaseMixin, AndroidMixin): def check_errors(self): if self._errored: self.info("Errors encountered, terminating with error code...") - exit(EXIT_STATUS_DICT[TBPL_FAILURE]) + sys.exit(EXIT_STATUS_DICT[TBPL_FAILURE]) if __name__ == "__main__": diff --git a/tools/mach_commands.py b/tools/mach_commands.py @@ -267,7 +267,8 @@ def npm(command_context, args): # in the wrong places and probably other badness too without this: npm_path, _ = find_npm_executable() if not npm_path: - exit(-1, "could not find npm executable") + print("error: could not find npm executable") + sys.exit(-1) path = os.path.abspath(os.path.dirname(npm_path)) os.environ["PATH"] = "{}{}{}".format(path, os.pathsep, os.environ["PATH"])