From a696e3bc35ee5a32bf028b196a010bae2a401dde Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 30 Mar 2025 11:48:28 +0800 Subject: [PATCH] qa: Remove unnecessary global statements in tests Removes unused `global` statements from Python test files to fix flake8 F824 errors. Recent flake8 runs were failing with: ``` ./tasks/radosgw_admin.py:330:5: F824 `global log` is unused: name is never assigned in scope ./workunits/dencoder/test_readable.py:99:5: F824 `global incompat_paths` is unused: name is never assigned in scope ./workunits/dencoder/test_readable.py:164:5: F824 `global backward_compat` is unused: name is never assigned in scope ./workunits/dencoder/test_readable.py:165:5: F824 `global fast_shouldnt_skip` is unused: name is never assigned in scope ``` Since these variables are only being referenced and not assigned within their scopes, the `global` declarations are unnecessary and can be safely removed. This change: - Removes all flagged `global` statements - Fixes the failing flake8 checks in the CI pipeline - Maintains the original code behavior as variable references still work without the `global` keyword The `global` keyword is only needed when assigning to global variables within a function scope, not when simply referencing them. Signed-off-by: Kefu Chai (cherry picked from commit bcc275f98cb26c9432c320cd24ee93ff629e0574) --- qa/tasks/radosgw_admin.py | 1 - qa/workunits/dencoder/test_readable.py | 3 --- 2 files changed, 4 deletions(-) diff --git a/qa/tasks/radosgw_admin.py b/qa/tasks/radosgw_admin.py index fb82378761bc7..a53d2d4c26ade 100644 --- a/qa/tasks/radosgw_admin.py +++ b/qa/tasks/radosgw_admin.py @@ -327,7 +327,6 @@ def task(ctx, config): """ Test radosgw-admin functionality against a running rgw instance. """ - global log assert ctx.rgw.config, \ "radosgw_admin task needs a config passed from the rgw task" diff --git a/qa/workunits/dencoder/test_readable.py b/qa/workunits/dencoder/test_readable.py index 6eba0a4eb3f4e..6253b26a72254 100755 --- a/qa/workunits/dencoder/test_readable.py +++ b/qa/workunits/dencoder/test_readable.py @@ -95,7 +95,6 @@ def process_type(file_path, type): return 0 # File passed the test def test_object_wrapper(type, vdir, arversion, current_ver): - global incompat_paths _numtests = 0 _failed = 0 unrecognized = "" @@ -155,8 +154,6 @@ def should_skip_object(type, arversion, current_ver): Note: The function relies on two global variables, 'backward_compat' and 'fast_shouldnt_skip', which should be defined and updated appropriately in the calling code. """ - global backward_compat - global fast_shouldnt_skip if type in fast_shouldnt_skip: debug_print(f"fast Type {type} does not exist in the backward compatibility structure.") -- 2.39.5