-
Notifications
You must be signed in to change notification settings - Fork 270
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
Fix pylint warnings #1584
Fix pylint warnings #1584
Conversation
Pull Request Test Coverage Report for Build 1246105286Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at a few cases and pylint is correct: those globals are not needed.
global
is only required if you want to assign to the global variable. mutating the value of that variable does not require global.
these third party documentation sites have really variable quality... The whole point of I try to find references for this sort of things on python.org (the search engines really fail hard with python searches, always offering this sort of pages before python.org content) |
d4b6632
to
47eee7c
Compare
New pylint warnings appeared with code "W0602: Using global for X but no assignment is done (global-variable-not-assigned)" where X is a global variable. In the lines pointed by the warnings, "global" was used inside a function scope in order to enable assignment of the global variable to a new value in the function. The reason for these warnings was that pylint noticed we are using "global" for the variable X inside a function scope without actually assigning it to a new value. Overall that was true for the reported cases and I removed the use of "global", but there were only two cases where pylint reported a false-positive. Then we were using "global", but pylint didn't understand there were assignments. In those cases, I disabled the warnings. Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
47eee7c
to
1a96bdd
Compare
Updated the pr and removed all but two occurrences of
Yes, you are right. Removed the link from the commit message and pr description.
I can't find where on python org globals are mentioned and that's why I won't give a link. |
Simplify the code by removing some of the uses of "global" by using alternativies to the assignements. Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-55 lines, fixes CI
Nice
Please fill in the fields below to submit a pull request. The more information
that is provided, the better.
Description of the changes being introduced by the pull request:
New pylint warnings appeared (for the first time here: https://github.com/theupdateframework/python-tuf/pull/1446/checks?check_run_id=3630842220) with code:
W0602: Using global for X but no assignment is done (global-variable-not-assigned)
where X is a global variable.
In the lines pointed by the warnings, "global" was used inside a
function scope in order to enable assignment of the global variable to
a new value in the function.
The reason for these warnings was that pylint noticed we are using
"global" for the variable X inside a function scope without actually
assigning it to a new value.
Overall that was true for the reported cases and I removed the use of
"global", but there were only two cases where pylint reported a
false-positive. Then we were using "global", but pylint didn't
understand there were assignments.
In those cases, I disabled the warnings.
Signed-off-by: Martin Vrachev mvrachev@vmware.com
Please verify and check that the pull request fulfills the following
requirements: