From 886c03cf2ac8758519dfd50c12b486d76d231d0d Mon Sep 17 00:00:00 2001 From: Laura M?dioni Date: Tue, 24 Nov 2015 11:46:44 +0100 Subject: Add is to the checked operators --- pylint/checkers/base.py | 2 +- pylint/test/functional/unneeded_not.py | 2 ++ pylint/test/functional/unneeded_not.txt | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) 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'" -- cgit v1.2.1