gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / pylint / test / functional / unneeded_not.py @ 745
History | View | Annotate | Download (1.56 KB)
1 |
"""Check exceeding negations in boolean expressions trigger warnings"""
|
---|---|
2 |
|
3 |
# pylint: disable=singleton-comparison,too-many-branches,too-few-public-methods,undefined-variable
|
4 |
|
5 |
def unneeded_not(): |
6 |
"""This is not ok
|
7 |
"""
|
8 |
bool_var = True
|
9 |
someint = 2
|
10 |
if not not bool_var: # [unneeded-not] |
11 |
pass
|
12 |
if not someint == 1: # [unneeded-not] |
13 |
pass
|
14 |
if not someint != 1: # [unneeded-not] |
15 |
pass
|
16 |
if not someint < 1: # [unneeded-not] |
17 |
pass
|
18 |
if not someint > 1: # [unneeded-not] |
19 |
pass
|
20 |
if not someint <= 1: # [unneeded-not] |
21 |
pass
|
22 |
if not someint >= 1: # [unneeded-not] |
23 |
pass
|
24 |
if not not someint: # [unneeded-not] |
25 |
pass
|
26 |
if not bool_var == True: # [unneeded-not] |
27 |
pass
|
28 |
if not bool_var == False: # [unneeded-not] |
29 |
pass
|
30 |
if not bool_var != True: # [unneeded-not] |
31 |
pass
|
32 |
if not True == True: # [unneeded-not] |
33 |
pass
|
34 |
if not 2 in [3, 4]: # [unneeded-not] |
35 |
pass
|
36 |
if not someint is 'test': # [unneeded-not] |
37 |
pass
|
38 |
|
39 |
|
40 |
def tolerated_statements(): |
41 |
"""This is ok"""
|
42 |
bool_var = True
|
43 |
someint = 2
|
44 |
if not(bool_var == False and someint == 1): |
45 |
pass
|
46 |
if 2 not in [3, 4]: |
47 |
pass
|
48 |
if not someint == bool_var == 2: |
49 |
pass
|
50 |
if not 2 <= someint < 3 < 4: |
51 |
pass
|
52 |
if not set('bar') <= set('foobaz'): |
53 |
pass
|
54 |
if not set(something) <= 3: |
55 |
pass
|
56 |
if not frozenset(something) <= 3: |
57 |
pass
|
58 |
|
59 |
|
60 |
class Klass(object): |
61 |
"""This is also ok"""
|
62 |
def __ne__(self, other): |
63 |
return not self == other |
64 |
|