]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: Remove unnecessary global statements in tests
authorKefu Chai <tchaikov@gmail.com>
Sun, 30 Mar 2025 03:48:28 +0000 (11:48 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sun, 30 Mar 2025 03:54:04 +0000 (11:54 +0800)
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 <tchaikov@gmail.com>
qa/tasks/radosgw_admin.py
qa/workunits/dencoder/test_readable.py

index fb82378761bc701bc42a18a8dfb26fc0cba4147b..a53d2d4c26ade893b77af36f25571fdacffbe62c 100644 (file)
@@ -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"
index 9665b1e257342df440ce9a8b8ffe93bf57764028..76b4e2489d4a9714169d47e2ba7c1aa2fbf1a1c2 100755 (executable)
@@ -96,7 +96,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 = ""
@@ -161,8 +160,6 @@ def should_skip_object(type, arversion, current_ver):
     Returns:
         bool: True if the object should be skipped, False otherwise.
     """
-    global backward_compat
-    global fast_shouldnt_skip
 
     # Validate global structures
     if not isinstance(backward_compat, dict) or not isinstance(fast_shouldnt_skip, list):