summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaura M?dioni <laura.medioni@logilab.fr>2015-11-24 11:46:44 +0100
committerLaura M?dioni <laura.medioni@logilab.fr>2015-11-24 11:46:44 +0100
commit886c03cf2ac8758519dfd50c12b486d76d231d0d (patch)
treef191cb95f308c84280eeeae18d7f0c8e9789eea3
parentcb68a81eee457947b9750013c90bcfeb4eb22bcf (diff)
downloadpylint-886c03cf2ac8758519dfd50c12b486d76d231d0d.tar.gz
Add is to the checked operators
-rw-r--r--pylint/checkers/base.py2
-rw-r--r--pylint/test/functional/unneeded_not.py2
-rw-r--r--pylint/test/functional/unneeded_not.txt1
3 files changed, 4 insertions, 1 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index aba648c..bccc967 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -1856,7 +1856,7 @@ class NotChecker(_BasicChecker):
}
reverse_op = {'<': '>=', '<=': '>', '>': '<=', '>=': '<', '==': '!=',
- '!=': '==', 'in': 'not in'}
+ '!=': '==', 'in': 'not in', 'is': 'is not'}
@check_messages('unneeded-not')
def visit_unaryop(self, node):
diff --git a/pylint/test/functional/unneeded_not.py b/pylint/test/functional/unneeded_not.py
index 78bf87c..0f56218 100644
--- a/pylint/test/functional/unneeded_not.py
+++ b/pylint/test/functional/unneeded_not.py
@@ -33,6 +33,8 @@ def unneeded_not():
pass
if not 2 in [3, 4]: # [unneeded-not]
pass
+ if not someint is 'test': # [unneeded-not]
+ pass
def not_checked():
diff --git a/pylint/test/functional/unneeded_not.txt b/pylint/test/functional/unneeded_not.txt
index b962293..13b3512 100644
--- a/pylint/test/functional/unneeded_not.txt
+++ b/pylint/test/functional/unneeded_not.txt
@@ -11,3 +11,4 @@ unneeded-not:28:unneeded_not:Consider changing "not bool_var == False" to "bool_
unneeded-not:30:unneeded_not:Consider changing "not bool_var != True" to "bool_var == True"
unneeded-not:32:unneeded_not:Consider changing "not True == True" to "True != True"
unneeded-not:34:unneeded_not:Consider changing "not 2 in [3, 4]" to "2 not in [3, 4]"
+unneeded-not:36:unneeded_not:Consider changing "not someint is 'test'" to "someint is not 'test'"