cephfs-top, qa: Remove unnecessary global statements in tests#62567
Merged
cephfs-top, qa: Remove unnecessary global statements in tests#62567
Conversation
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>
Contributor
Author
|
for an instance of the test failure addressed by this change, see https://jenkins.ceph.com/job/ceph-pull-requests/154956/consoleFull#868021901e840cee4-f4a4-4183-81dd-42855615f2c1: |
Recent flake8 runs were failing with: ``` py3: flake8==7.2.0,mccabe==0.7.0,pip==25.0.1,pycodestyle==2.13.0,pyflakes==3.3.0,setuptools==75.8.0,wheel==0.45.1 py3: commands[0] /home/jenkins-build/build/workspace/ceph-pull-requests/src/tools/cephfs/top> flake8 --ignore=W503 --max-line-length=100 cephfs-top cephfs-top:344:9: F824 `global fs_list` is unused: name is never assigned in scope cephfs-top:466:13: F824 `global current_states` is unused: name is never assigned in scope cephfs-top:872:9: F824 `global metrics_dict` is unused: name is never assigned in scope cephfs-top:872:9: F824 `global current_states` is unused: name is never assigned in scope cephfs-top:911:9: F824 `global fs_list` is unused: name is never assigned in scope cephfs-top:981:9: F824 `global current_states` is unused: name is never assigned in scope cephfs-top:1126:13: F824 `global current_states` is unused: name is never assigned in scope py3: exit 1 (0.77 seconds) /home/jenkins-build/build/workspace/ceph-pull-requests/src/tools/cephfs/top> flake8 --ignore=W503 --max-line-length=100 cephfs-top pid=2309605 py3: FAIL code 1 (8.15=setup[7.38]+cmd[0.77] seconds) evaluation failed :( (8.24 seconds) ``` 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>
This was referenced Mar 30, 2025
Contributor
|
LGTM (but I cannot approve a CephFS PR...) |
ronen-fr
approved these changes
Mar 30, 2025
Contributor
Author
@ronen-fr hi Ronen, thank you for your review and approval. i will wait for 2 more days before merging this change. it's urgent, because the CI tests in all PRs are now failing. |
14 tasks
phlogistonjohn
approved these changes
Mar 31, 2025
Contributor
|
I think you should feel free to merge as soon as you are ready as tests continue to fail without these changes. |
Contributor
This was referenced Apr 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes unused
globalstatements to fix flake8 F824 errors.Recent flake8 runs were failing with:
Since these variables are only being referenced and not assigned within their scopes, the
globaldeclarations are unnecessary and can be safely removed. This change:globalstatementsglobalkeywordThe
globalkeyword is only needed when assigning to global variables within a function scope, not when simply referencing them.Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job Definition