summaryrefslogtreecommitdiff
path: root/pylint/test/functional/unneeded_not.py
diff options
context:
space:
mode:
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