-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
False negative global-variable-not-assigned (while respective functional test passes correctly) #1375
Comments
It's correct message. Global is not needed in included code snippet.
Dnia 11.03.2017 o godz. 18:13 eight <notifications@github.com> napisał(a):
… Steps to reproduce
Try to lint following code:
a = 1
def foo():
global a
print(a)
Current behavior
No config file found, using default configuration
************* Module test
W: 3, 0: Found indentation with tabs instead of spaces (mixed-indentation)
W: 4, 0: Found indentation with tabs instead of spaces (mixed-indentation)
C: 1, 0: Missing module docstring (missing-docstring)
C: 1, 0: Invalid constant name "a" (invalid-name)
C: 2, 0: Black listed name "foo" (blacklisted-name)
C: 2, 0: Missing function docstring (missing-docstring)
C: 3, 1: Invalid constant name "a" (invalid-name)
W: 3, 1: Using the global statement (global-statement)
Expected behavior
W: 3, 1: Using global for 'a' but no assignment is done (global-variable-not-as
signed)
pylint --version output
pylint 1.7.0,
astroid 1.5.0
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (In
tel)]
It is reported correctly in pylint 1.6.5.
No config file found, using default configuration
************* Module test
W: 3, 0: Found indentation with tabs instead of spaces (mixed-indentation)
W: 4, 0: Found indentation with tabs instead of spaces (mixed-indentation)
C: 1, 0: Missing module docstring (missing-docstring)
C: 1, 0: Invalid constant name "a" (invalid-name)
C: 2, 0: Black listed name "foo" (blacklisted-name)
C: 2, 0: Missing function docstring (missing-docstring)
W: 3, 1: Using global for 'a' but no assignment is done (global-variable-not-as
signed)
C: 3, 1: Invalid constant name "a" (invalid-name)
__main__.py 1.6.5,
astroid 1.4.9
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 15:51:26) [MSC v.1900 32 bit (In
tel)]
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Closing as not-a-bug. |
Does it mean that |
No, those are two independent checks, and each of them mean different thing.
|
Code snippet shown below will correctly not emit
Code snippet shown in this bug correctly emits |
|
pylint --version
pip freeze
test.py
pylint test
|
Ugh, it seems like I misread problem statement, sorry about that. It's quite surprising, there is a very similar test in test suite that passes successfully. |
I got an error when installing editdistance. The log. However, if I run
|
This checker now checks whether the names after the global keyword are reassigned in the local scope. This closes pylint-dev#1375
This checker now checks whether the names after the global keyword are reassigned in the local scope. This closes pylint-dev#1375
This checker now checks whether the names after the global keyword are reassigned in the local scope. This closes pylint-dev#1375
* Make ``global-variable-not-assigned`` check local scope This checker now checks whether the names after the global keyword are reassigned in the local scope. This closes #1375 * Make ``global-variable-not-assigned`` check functions This checker now also checks function defintions in the module and local scope This closes #330 Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
If there is no write access, there is no need for global. Remove global statement if there is no assignment. global-variable-not-assigned: Using global for names but no assignment is done Used when a variable is defined through the "global" statement but no assignment to this variable is done. In Pylint 2.11 the global-variable-not-assigned checker now catches global variables that are never reassigned in a local scope and catches (reassigned) functions [1][2] [1] https://pylint.pycqa.org/en/latest/whatsnew/2.11.html [2] pylint-dev/pylint#1375 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Steps to reproduce
Try to lint following code:
Current behavior
Expected behavior
pylint --version output
It is reported correctly in pylint 1.6.5.
The text was updated successfully, but these errors were encountered: