commit 491e058e06f60cf57ec17550ee7388dac76dc3b4 parent 672ac9af9d28b30230f36280af1dbfd1bc47bc4a Author: Alex Hochheiden <ahochheiden@mozilla.com> Date: Wed, 10 Dec 2025 06:03:26 +0000 Bug 2003412 - Fix PLW0602 warnings: Remove unnecessary global declaration r=emilio,perftest-reviewers,geckoview-reviewers,tcampbell,sparky https://docs.astral.sh/ruff/rules/global-variable-not-assigned/ Differential Revision: https://phabricator.services.mozilla.com/D274702 Diffstat:
13 files changed, 4 insertions(+), 23 deletions(-)
diff --git a/js/src/gdb/mozilla/prettyprinters.py b/js/src/gdb/mozilla/prettyprinters.py @@ -127,8 +127,7 @@ def pretty_printer_for_regexp(pattern, name): def clear_module_printers(module_name): - global printers_by_tag, ptr_printers_by_tag, ref_printers_by_tag - global template_printers_by_tag, printers_by_regexp + global printers_by_regexp # Remove all pretty-printers defined in the module named |module_name| # from d. diff --git a/mobile/android/gradle/plugins/apilint/apilint/src/main/resources/apilint.py b/mobile/android/gradle/plugins/apilint/apilint/src/main/resources/apilint.py @@ -594,7 +594,6 @@ failures = {} def _fail(clazz, detail, error, rule, msg): """Records an API failure to be processed later.""" - global failures sig = "%s-%s-%s" % (clazz.fullname, repr(detail), msg) sig = sig.replace(" deprecated ", " ") @@ -614,7 +613,6 @@ noticed = {} def notice(clazz): - global noticed noticed[clazz.fullname] = clazz @@ -2630,7 +2628,6 @@ def verify_compat(cur, prev): def show_deprecations_at_birth(cur, prev): """Show API deprecations at birth.""" - global failures # Remove all existing things so we're left with new for prev_clazz in prev.values(): diff --git a/python/mach/mach/test/zero_microseconds.py b/python/mach/mach/test/zero_microseconds.py @@ -8,7 +8,6 @@ old = self._mach_context.post_dispatch_handler def handler(context, handler, instance, result, start_time, end_time, depth, args): - global old # Round off sub-second precision. old(context, handler, instance, result, int(start_time), end_time, depth, args) diff --git a/testing/mozbase/mozgeckoprofiler/mozgeckoprofiler/symFileManager.py b/testing/mozbase/mozgeckoprofiler/mozgeckoprofiler/symFileManager.py @@ -203,7 +203,6 @@ class SymFileManager: def PrefetchRecentSymbolFiles(self): """This method runs in a loop. Use the options "prefetchThreshold" to adjust""" - global PREFETCHED_LIBS LOG.info("Prefetching recent symbol files") # Schedule next timer callback diff --git a/testing/mozbase/mozlog/mozlog/structuredlog.py b/testing/mozbase/mozlog/mozlog/structuredlog.py @@ -135,8 +135,6 @@ def get_default_logger(component=None): :param component: The component name to tag log messages with """ - global _default_logger_name - if not _default_logger_name: return None diff --git a/testing/mozbase/mozrunner/mozrunner/application.py b/testing/mozbase/mozrunner/mozrunner/application.py @@ -112,7 +112,6 @@ class FennecContext(RemoteContext): # Create a mozdevice.ADBDevice object for the specified device_serial # and cache it for future use. If the same device_serial is subsequently # requested, retrieve it from the cache to avoid costly re-initialization. - global devices if device_serial in devices: device = devices[device_serial] else: diff --git a/testing/performance/hooks_recording.py b/testing/performance/hooks_recording.py @@ -105,7 +105,6 @@ def before_iterations(kw): def before_runs(env): - global next_site print("Running before_runs") add_options(env, options) diff --git a/testing/talos/talos/filter.py b/testing/talos/talos/filter.py @@ -57,15 +57,11 @@ def register_filter(func): all filters defined in this module should be registered """ - global _FILTERS - _FILTERS[func.__name__] = func return func def filters(*args): - global _FILTERS - filters_ = [_FILTERS[filter] for filter in args] return filters_ diff --git a/testing/talos/talos/xtalos/etlparser.py b/testing/talos/talos/xtalos/etlparser.py @@ -225,7 +225,6 @@ def trackProcess(row, firstFirefoxPID): def getBrowserPID(): - global gBrowserPID return gBrowserPID @@ -348,7 +347,6 @@ def etlparser( all_threads=False, debug=False, ): - global NAME_SUBSTITUTIONS # setup output file if outputFile: diff --git a/testing/xpcshell/runxpcshelltests.py b/testing/xpcshell/runxpcshelltests.py @@ -1934,7 +1934,6 @@ class XPCShellTests: """ Run xpcshell tests. """ - global gotSIGINT # Number of times to repeat test(s) in --verify mode VERIFY_REPEAT = 10 diff --git a/toolkit/components/gecko-trace/scripts/codegen.py b/toolkit/components/gecko-trace/scripts/codegen.py @@ -79,10 +79,10 @@ def load_schema_index(): with open(index) as f: index_src = f.read() - global gecko_trace_files - exec(index_src, globals()) + namespace = {} + exec(index_src, namespace) - return [str(Path(topsrcdir) / x) for x in gecko_trace_files] # type: ignore + return [str(Path(topsrcdir) / x) for x in namespace["gecko_trace_files"]] @memoize diff --git a/tools/lint/eslint/setup_helper.py b/tools/lint/eslint/setup_helper.py @@ -396,7 +396,6 @@ def get_project_root(): """Returns the absolute path to the root of the project, see set_project_root() for how this is determined. """ - global project_root if not project_root: set_project_root() diff --git a/tools/lint/test/test_clippy.py b/tools/lint/test/test_clippy.py @@ -89,7 +89,6 @@ def test_fix_non_gkrust(lint, paths, create_temp_file): path = create_temp_file(contents, "non_gkrust_fixable.rs") # Reset the fixed counter - global fixed fixed_before = fixed # Run clippy with fix=True