summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-11-25 20:20:20 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2015-11-25 20:20:20 +0200
commit2ed3ef86a38e6672ece3886359b9f1b86333a197 (patch)
treeea944de6ea3273f69c7f5aece3c9bca534b168b8
parent67e2a874210b3d2a5bee4fa8b636e79f0612c3f7 (diff)
parentee4beb760c26bb26f9acefddfef5d6315e201f34 (diff)
downloadpylint-2ed3ef86a38e6672ece3886359b9f1b86333a197.tar.gz
Merged in lmedioni/pylint (pull request #306)
Ignore multiple comparisons in unneeded-not rule
-rw-r--r--pylint/checkers/base.py3
-rw-r--r--pylint/test/functional/unneeded_not.py4
2 files changed, 7 insertions, 0 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index bccc967..73e0315 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -1869,6 +1869,9 @@ class NotChecker(_BasicChecker):
operand.operand.as_string()))
elif isinstance(operand, astroid.Compare):
left = operand.left
+ # ignore multiple comparisons
+ if len(operand.ops) > 1:
+ return
operator, right = operand.ops[0]
if operator not in self.reverse_op:
return
diff --git a/pylint/test/functional/unneeded_not.py b/pylint/test/functional/unneeded_not.py
index 0f56218..8f7ba93 100644
--- a/pylint/test/functional/unneeded_not.py
+++ b/pylint/test/functional/unneeded_not.py
@@ -45,3 +45,7 @@ def not_checked():
pass
if 2 not in [3, 4]:
pass
+ if not someint == bool_var == 2:
+ pass
+ if not 2 <= someint < 3 < 4:
+ pass