-
-
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
unused-variable
false-positive regression for argparse.Namespace
#6895
Comments
@jacobtylerwalls This is a strange one. There seems to be inter-dependency between the variables checker and the Reproducer with this diff: diff --git a/pylint/checkers/classes/special_methods_checker.py b/pylint/checkers/classes/special_methods_checker.py
index 9a7c9a762..5c60e6637 100644
--- a/pylint/checkers/classes/special_methods_checker.py
+++ b/pylint/checkers/classes/special_methods_checker.py
@@ -132,7 +132,7 @@ class SpecialMethodsChecker(BaseChecker):
"of the form tuple(tuple, dict)",
),
}
- priority = -2
+ priority = -99
def __init__(self, linter=None):
super().__init__(linter)
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index ef6a5369f..4cb7059d0 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -984,7 +984,7 @@ class VariablesChecker(BaseChecker):
name = "variables"
msgs = MSGS
- priority = -1
+ priority = -999
options = (
(
"init-import",
@@ -1264,6 +1264,7 @@ class VariablesChecker(BaseChecker):
self._store_type_annotation_node(argument_annotation)
not_consumed = self._to_consume.pop().to_consume
+ print(not_consumed)
if not (
self.linter.is_message_enabled("unused-variable")
or self.linter.is_message_enabled("possibly-unused-variable") ❯ git checkout f46904ab9b058d8506b87cedd1f0c710d5c19360
❯ git apply diff
❯ pylint test.py
************* Module test
test.py:7:4: R0201: Method could be a function (no-self-use)
{'self': [<AssignName.self l.7 at 0x102644820>], 'Namespace': [<ClassDef.Namespace l.8 at 0x102710610>]}
test.py:8:0: W0612: Unused variable 'Namespace' (unused-variable)
------------------------------------------------------------------
Your code has been rated at 5.00/10 (previous run: 5.00/10, +0.00) Then change the priority of ❯ pylint test.py
************* Module test
test.py:7:4: R0201: Method could be a function (no-self-use)
{'self': [<AssignName.self l.7 at 0x107fe8820>]}
------------------------------------------------------------------
Your code has been rated at 7.50/10 (previous run: 5.00/10, +2.50) Do you have any idea how/why these checkers are connected? I did some quick looking around but couldn't immediately find why |
It's another manifestation of pylint-dev/astroid#1490. I'll open a backportable PR in
The special methods checker uses inference, and so we hit the argparse.Namespace brain, and that chokes on pylint-dev/astroid#1490 and incorrectly adds the parent's name ( |
Thanks for the investigation @jacobtylerwalls! |
* Upgrade astroid to 2.11.6 Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Bug description
With this file, there is a weird
unused-variable
:seems to work fine with the function outside of the class...
Bisected to e01fa86 ("Remove the concept of checker priority (#6034)"), cc @DanielNoord
Configuration
No response
Command used
Pylint output
Expected behavior
No errors
Pylint version
OS / Environment
Archlinux
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: