commit 2bb010077c16c4a00959d8ca643b831586fecf64 parent 306d5da462a3042b9c9d1b76e36cd5c99dddb051 Author: Alex Hochheiden <ahochheiden@mozilla.com> Date: Wed, 10 Dec 2025 06:03:21 +0000 Bug 2003412 - Fix UP030 warnings: Use implicit references for positional format fields r=emilio,perftest-reviewers,jdescottes,sparky https://docs.astral.sh/ruff/rules/format-literals/ Differential Revision: https://phabricator.services.mozilla.com/D274686 Diffstat:
17 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/config/printprereleasesuffix.py b/config/printprereleasesuffix.py @@ -17,7 +17,7 @@ def get_prerelease_suffix(version): """Returns the prerelease suffix from the version string argument""" def mfunc(m): - return " {0} {1} {2}".format( + return " {} {} {}".format( m.group("prefix"), {"a": "Alpha", "b": "Beta"}[m.group("c")], m.group("suffix"), diff --git a/config/tests/unitMozZipFile.py b/config/tests/unitMozZipFile.py @@ -62,7 +62,7 @@ def prod(*iterables): def getid(descs): "Convert a list of ints to a string." - return reduce(lambda x, y: x + "{0}{1}".format(*tuple(y)), descs, "") + return reduce(lambda x, y: x + "{}{}".format(*tuple(y)), descs, "") def getContent(length): diff --git a/gfx/layers/d3d11/genshaders.py b/gfx/layers/d3d11/genshaders.py @@ -95,7 +95,7 @@ def run_fxc(shader_model, shader_file, shader_name, output_fp): with ScopedTempFilename() as temp_filename: argv += [f"-Fh{os.path.relpath(temp_filename)}"] - sys.stdout.write("{0}\n".format(" ".join(argv))) + sys.stdout.write("{}\n".format(" ".join(argv))) sys.stdout.flush() proc_stdout = subprocess.check_output(argv) proc_stdout = decode_console_text(sys.stdout, proc_stdout) diff --git a/js/src/devtools/automation/autospider.py b/js/src/devtools/automation/autospider.py @@ -315,8 +315,8 @@ if word_bits == 32: sse_flags = "-arch:SSE2" else: sse_flags = "-msse -msse2 -mfpmath=sse" - env["CCFLAGS"] = "{0} {1}".format(env.get("CCFLAGS", ""), sse_flags) - env["CXXFLAGS"] = "{0} {1}".format(env.get("CXXFLAGS", ""), sse_flags) + env["CCFLAGS"] = "{} {}".format(env.get("CCFLAGS", ""), sse_flags) + env["CXXFLAGS"] = "{} {}".format(env.get("CXXFLAGS", ""), sse_flags) else: if platform.system() == "Windows": CONFIGURE_ARGS += " --target=x86_64-pc-windows-msvc" diff --git a/memory/replace/dmd/dmd.py b/memory/replace/dmd/dmd.py @@ -816,7 +816,7 @@ def printDigest(args, digest): def prettyPrintDmdJson(out, j): out.write("{\n") - out.write(' "version": {0},\n'.format(j["version"])) + out.write(' "version": {},\n'.format(j["version"])) out.write(' "invocation": ') json.dump(j["invocation"], out, sort_keys=True) out.write(",\n") diff --git a/python/mozbuild/mozbuild/action/langpack_manifest.py b/python/mozbuild/mozbuild/action/langpack_manifest.py @@ -525,7 +525,7 @@ def create_webmanifest( assert entry["alias"] not in cr cr[entry["alias"]] = entry["path"] else: - raise Exception("Unknown type {0}".format(entry["type"])) + raise Exception("Unknown type {}".format(entry["type"])) for loc in locales: manifest["languages"][loc] = { diff --git a/python/mozbuild/mozbuild/jar.py b/python/mozbuild/mozbuild/jar.py @@ -490,7 +490,7 @@ class JarMaker: if jf is not None: jf.close() raise RuntimeError( - 'File "{0}" not found in {1}'.format(src, ", ".join(src_base)) + 'File "{}" not found in {}'.format(src, ", ".join(src_base)) ) if out in self._seen_output: diff --git a/python/mozbuild/mozbuild/test/test_jarmaker.py b/python/mozbuild/mozbuild/test/test_jarmaker.py @@ -161,13 +161,13 @@ class _TreeDiff(dircmp): self._fillDiff(self, rv) chunks = [] if rv["right_only"]: - chunks.append("{0} only in {1}".format(", ".join(rv["right_only"]), right)) + chunks.append("{} only in {}".format(", ".join(rv["right_only"]), right)) if rv["left_only"]: - chunks.append("{0} only in {1}".format(", ".join(rv["left_only"]), left)) + chunks.append("{} only in {}".format(", ".join(rv["left_only"]), left)) if rv["diff_files"]: - chunks.append("{0} differ".format(", ".join(rv["diff_files"]))) + chunks.append("{} differ".format(", ".join(rv["diff_files"]))) if rv["funny"]: - chunks.append("{0} don't compare".format(", ".join(rv["funny"]))) + chunks.append("{} don't compare".format(", ".join(rv["funny"]))) return "; ".join(chunks) diff --git a/python/mozversioncontrol/mozversioncontrol/repo/git.py b/python/mozversioncontrol/mozversioncontrol/repo/git.py @@ -273,7 +273,7 @@ class GitRepository(Repository): if pattern.startswith("^"): magics += ["top"] pattern = pattern[1:] - return ":({0}){1}".format(",".join(magics), pattern) + return ":({}){}".format(",".join(magics), pattern) def diff_stream(self, rev=None, extensions=(), exclude_file=None, context=8): commit_range = "HEAD" # All uncommitted changes. diff --git a/testing/marionette/client/marionette_driver/wait.py b/testing/marionette/client/marionette_driver/wait.py @@ -148,12 +148,12 @@ class Wait: if message: message = f" with message: {message}" + else: + message = "" + elapsed = round(self.clock.now - start, 1) raise errors.TimeoutException( - # pylint: disable=W1633 - "Timed out after {0:.1f} seconds{1}".format( - float(round((self.clock.now - start), 1)), message if message else "" - ), + f"Timed out after {elapsed:.1f} seconds{message}", cause=last_exc, ) diff --git a/testing/marionette/harness/marionette_harness/runner/base.py b/testing/marionette/harness/marionette_harness/runner/base.py @@ -48,7 +48,7 @@ class MarionetteTest(TestResult): @property def test_name(self): if self.test_class is not None: - return "{0}.py {1}.{2}".format( + return "{}.py {}.{}".format( self.test_class.split(".")[0], self.test_class, self.name ) else: diff --git a/testing/marionette/harness/marionette_harness/runner/httpd.py b/testing/marionette/harness/marionette_harness/runner/httpd.py @@ -231,7 +231,7 @@ e.g. \"https://0.0.0.0:0/base/\"""", ) httpd.start() print( - "{0}: started fixture server on {1}".format(sys.argv[0], httpd.get_url("/")), + "{}: started fixture server on {}".format(sys.argv[0], httpd.get_url("/")), file=sys.stderr, ) httpd.wait() diff --git a/testing/raptor/raptor/chrome_trace.py b/testing/raptor/raptor/chrome_trace.py @@ -35,7 +35,7 @@ class ChromeTrace(RaptorProfiling): # Make sure no archive already exists in the location where # we plan to output our profiler archive self.profile_arcname = Path( - self.upload_dir, "profile_{0}.zip".format(self.test_config["name"]) + self.upload_dir, "profile_{}.zip".format(self.test_config["name"]) ) LOG.info(f"Clearing archive {self.profile_arcname}") mozfile.remove(self.profile_arcname) @@ -91,7 +91,7 @@ class ChromeTrace(RaptorProfiling): try: test_run_type = ( - "{0}-{1}".format(test_type, profile_info["type"]) + "{}-{}".format(test_type, profile_info["type"]) if test_type == "pageload" else test_type ) diff --git a/testing/raptor/raptor/cmdline.py b/testing/raptor/raptor/cmdline.py @@ -717,7 +717,7 @@ class _PrintTests(_StopAction): subtest = next_test["name"] measure = next_test.get("measure") if measure is not None: - subtest = "{0} ({1})".format( + subtest = "{} ({})".format( subtest, measure.replace("\n", ", ") ) test_list[suite]["subtests"].append(subtest) diff --git a/testing/raptor/raptor/gecko_profile.py b/testing/raptor/raptor/gecko_profile.py @@ -63,7 +63,7 @@ class GeckoProfile(RaptorProfiling): # Make sure no archive already exists in the location where # we plan to output our profiler archive self.profile_arcname = os.path.join( - self.upload_dir, "profile_{0}.zip".format(self.test_config["name"]) + self.upload_dir, "profile_{}.zip".format(self.test_config["name"]) ) LOG.info(f"Clearing archive {self.profile_arcname}") mozfile.remove(self.profile_arcname) @@ -193,7 +193,7 @@ class GeckoProfile(RaptorProfiling): # to clearly indicate without redundant information. # For example, "browser-cycle-1". test_run_type = ( - "{0}-{1}".format(test_type, profile_info["type"]) + "{}-{}".format(test_type, profile_info["type"]) if test_type == "pageload" else test_type ) diff --git a/testing/talos/talos/gecko_profile.py b/testing/talos/talos/gecko_profile.py @@ -61,7 +61,7 @@ class GeckoProfile: # the test name self.profile_arcname = os.path.join( self.upload_dir, - "profile_{0}.zip".format(test_config.get("suite", test_config["name"])), + "profile_{}.zip".format(test_config.get("suite", test_config["name"])), ) # We delete the archive if the current test is the first in the suite @@ -214,7 +214,7 @@ class GeckoProfile: # 'profile_tscrollx/iframe.svg/cycle_0.profile'. cycle_name = f"cycle_{cycle}.profile" path_in_zip = os.path.join( - "profile_{0}".format(self.test_config["name"]), testname, cycle_name + "profile_{}".format(self.test_config["name"]), testname, cycle_name ) LOG.info( f"Adding profile {path_in_zip} to archive {self.profile_arcname}" diff --git a/toolkit/xre/test/marionette/gen_win32k_tests.py b/toolkit/xre/test/marionette/gen_win32k_tests.py @@ -28,7 +28,7 @@ def start_test(line): def set_default(d): output.write( """ - if self.default_is is not {0}: + if self.default_is is not {}: return\n""".format( "True" if d == "T" else "False" ) @@ -75,7 +75,7 @@ def set_header(enable): def set_bad_requirements(enabled): output.write( """ - self.marionette.set_pref(Prefs.WEBGL, {0})\n""".format( + self.marionette.set_pref(Prefs.WEBGL, {})\n""".format( "False" if enabled else "True" ) ) @@ -91,11 +91,11 @@ def print_assertion(assertion): output.write( """ self.check_win32k_status( - status=ContentWin32kLockdownState.{0}, - sessionStatus=ContentWin32kLockdownState.{1}, - experimentStatus=ExperimentStatus.{2}, - pref={3}, - enrollmentStatusPref=ExperimentStatus.{4}, + status=ContentWin32kLockdownState.{}, + sessionStatus=ContentWin32kLockdownState.{}, + experimentStatus=ExperimentStatus.{}, + pref={}, + enrollmentStatusPref=ExperimentStatus.{}, )\n""".format( *assertion )