blob: 7006d4960b41f81be9834573f6d4f8027da798cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# pylint: disable = disallowed-name, missing-docstring, useless-return, invalid-name, line-too-long, comparison-of-constants, broad-exception-raised
def foo():
return None
def goo():
return None
if foo == 786: # [comparison-with-callable]
pass
if 666 == goo: # [comparison-with-callable]
pass
if foo == goo:
pass
if foo() == goo():
pass
class FakeClass:
def __init__(self):
self._fake_prop = 'fake it till you make it!!'
def fake_method(self):
return '666 - The Number of the Beast'
@property
def fake_property(self):
return self._fake_prop
@fake_property.setter
def fake_property(self, prop):
self._fake_prop = prop
obj1 = FakeClass()
obj2 = FakeClass()
if obj1.fake_method == obj2.fake_method:
pass
if obj1.fake_property != obj2.fake_property: # property although is function but is called without parenthesis
pass
if obj1.fake_method != foo:
pass
if obj1.fake_method != 786: # [comparison-with-callable]
pass
if obj1.fake_method != obj2.fake_property: # [comparison-with-callable]
pass
if 666 == 786:
pass
a = 666
b = 786
if a == b:
pass
def eventually_raise():
print()
raise Exception
if a == eventually_raise:
# Does not emit comparison-with-callable because the
# function (eventually) raises
pass
|