summaryrefslogtreecommitdiff
path: root/pylint/test/functional/unneeded_not.py
diff options
context:
space:
mode:
authorLaura M?dioni <laura.medioni@logilab.fr>2015-10-26 09:35:59 +0100
committerLaura M?dioni <laura.medioni@logilab.fr>2015-10-26 09:35:59 +0100
commit3820ddea785c532428642ae2f96d9e8bff244fbf (patch)
treed391102c5ff6157bae0b50392c5acdbf51d0a6c2 /pylint/test/functional/unneeded_not.py
parent6f59c12b55765a3cc721864e8882f1e8e49bcb58 (diff)
downloadpylint-3820ddea785c532428642ae2f96d9e8bff244fbf.tar.gz
Check for nots too many in comparison expressions
Diffstat (limited to 'pylint/test/functional/unneeded_not.py')
-rw-r--r--pylint/test/functional/unneeded_not.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/pylint/test/functional/unneeded_not.py b/pylint/test/functional/unneeded_not.py
new file mode 100644
index 0000000..882a238
--- /dev/null
+++ b/pylint/test/functional/unneeded_not.py
@@ -0,0 +1,41 @@
+"""Check exceeding negations in boolean expressions trigger warnings"""
+
+# pylint: disable=singleton-comparison
+
+def unneeded_not():
+ """This is not ok
+ """
+ bool_var = True
+ someint = 2
+ if not not bool_var: # [unneeded-not]
+ pass
+ if not someint == 1: # [unneeded-not]
+ pass
+ if not someint != 1: # [unneeded-not]
+ pass
+ if not someint < 1: # [unneeded-not]
+ pass
+ if not someint > 1: # [unneeded-not]
+ pass
+ if not someint <= 1: # [unneeded-not]
+ pass
+ if not someint >= 1: # [unneeded-not]
+ pass
+ if not not someint: # [unneeded-not]
+ pass
+ if not bool_var == True: # [unneeded-not]
+ pass
+ if not bool_var == False: # [unneeded-not]
+ pass
+ if not bool_var != True: # [unneeded-not]
+ pass
+ if not True == True: # [unneeded-not]
+ pass
+
+
+def not_checked():
+ """This is ok"""
+ bool_var = True
+ someint = 2
+ if not(bool_var == False and someint == 1):
+ pass