Skip to content

remove useless 'global' statements #4836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

boegel
Copy link
Member

@boegel boegel commented Apr 2, 2025

global statements are only required when a function or method redefines a global variable (like in dry_run_set_dirs in easybuild.tools.build_log).

This fixes a failing code style check caught by new version of flake8:

./easybuild/framework/easyconfig/format/version.py:502:9: F824 `global TOOLCHAIN_NAMES` is unused: name is never assigned in scope
./easybuild/main.py:243:5: F824 `global _log` is unused: name is never assigned in scope

@boegel boegel added the bug fix label Apr 2, 2025
@boegel boegel added this to the release after 5.0.0 milestone Apr 2, 2025
@@ -615,7 +611,6 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None, pr

options, orig_paths = eb_go.options, eb_go.args

global _log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is needed isn't it as you set it below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, that's kind of hidden...

You're right.

@boegel
Copy link
Member Author

boegel commented Apr 2, 2025

Part of changes originally proposed have already been made in #4831, but none of the global _log statements are required in main.py, so let's get rid of all of them...

@@ -308,7 +308,6 @@ def process_eb_args(eb_args, eb_go, cfg_settings, modtool, testing, init_session
"""
options = eb_go.options

global _log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is needed as you set it in the following line

@boegel
Copy link
Member Author

boegel commented Apr 2, 2025

Both remaining global _log statements are actually needed, since we're redefining _log in the line where cfg_settings is being "unpacked"...

So this PR is now useless, the required changes to get rid of the useless global statements have been made already through #4831

@boegel boegel closed this Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants