From 508befc5aefe6ffc5ea522455f744069efa1559f Mon Sep 17 00:00:00 2001 From: Laura M?dioni Date: Wed, 25 Nov 2015 14:19:14 +0100 Subject: Ignore multiple comparisons in unneeded-not rule related to issue #703 --- pylint/checkers/base.py | 3 +++ pylint/test/functional/unneeded_not.py | 4 ++++ 2 files changed, 7 insertions(+) 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 -- cgit v1.2.1