-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathtest.py
More file actions
129 lines (90 loc) · 1.97 KB
/
test.py
File metadata and controls
129 lines (90 loc) · 1.97 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#Consistent Returns
__all__ = [ '' ]
def ok1(x):
if x:
return None
else:
return
def ok2(x):
if x:
return 4
else:
return "Hi"
def cr1(x):
if x:
return 4
def cr2(x):
if x:
return 4
else:
return
def ok3(x):
try:
return
finally:
do_something()
#Modification of parameter with default
def ok4(x = []):
return len(x)
def mpd(x = []):
x.append("x")
def mpd2(x = []):
return x.append("x")
class ExplicitReturnNoneInInit(object):
def __init__(self):
return None
class PlainReturnInInit(object):
def __init__(self):
return
def error():
raise Exception()
class InitCallsError(object):
def __init__(self):
return error()
class InitCallsInit(InitCallsError):
def __init__(self):
return InitCallsError.__init__(self)
def use_implicit_return_value(arg):
x = do_nothing()
return call_non_callable(arg)
y = lambda x : do_nothing()
def do_nothing():
pass
#Using name other than 'cls' for first parameter in methods.
# This shouldn't apply to classmethods (first parameter should be 'cls' or similar)
# or static methods (first parameter can be anything)
class Normal(object):
def n_ok(self):
pass
@staticmethod
def n_smethod(ok):
pass
@classmethod
def n_cmethod(self):
pass
def return_value_ignored():
ok2()
ok4()
sorted([1,2])
d = {}
class InitCallsInit2(InitCallsError):
def __init__(self):
return super(InitCallsInit2, self).__init__()
#Harmless, so we allow it.
def use_implicit_return_value_ok(arg):
return do_nothing()
def multi_return(arg):
if arg:
return do_something()
else:
return do_nothing()
def do_something():
print ("Hello")
Normal().n_ok()
return 17
def with_flow():
x = do_something()
print("Bye")
return x
def return_default(x=()):
return x