inspect_fodder2.py 1.77 KB
Newer Older
1 2
# line 1
def wrap(foo=None):
Tim Peters's avatar
Tim Peters committed
3 4 5
    def wrapper(func):
        return func
    return wrapper
6 7 8

# line 7
def replace(func):
Tim Peters's avatar
Tim Peters committed
9
    def insteadfunc():
10
        print('hello')
Tim Peters's avatar
Tim Peters committed
11
    return insteadfunc
12 13 14 15 16

# line 13
@wrap()
@wrap(wrap)
def wrapped():
Tim Peters's avatar
Tim Peters committed
17
    pass
18 19 20 21

# line 19
@replace
def gone():
Tim Peters's avatar
Tim Peters committed
22
    pass
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

# line 24
oll = lambda m: m

# line 27
tll = lambda g: g and \
g and \
g

# line 32
tlli = lambda d: d and \
    d

# line 36
def onelinefunc(): pass

# line 39
def manyargs(arg1, arg2,
arg3, arg4): pass

# line 43
def twolinefunc(m): return m and \
m

# line 47
a = [None,
     lambda x: x,
     None]

# line 52
def setfunc(func):
    globals()["anonymous"] = func
setfunc(lambda x, y: x*y)
56 57 58 59 60 61 62

# line 57
def with_comment():  # hello
    world

# line 61
multiline_sig = [
63 64
    lambda x, \
            y: x+y,
65 66
    None,
    ]
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

# line 68
def func69():
    class cls70:
        def func71():
            pass
    return cls70
extra74 = 74

# line 76
def func77(): pass
(extra78, stuff78) = 'xy'
extra79 = 'stop'

# line 81
class cls82:
    def func83(): pass
(extra84, stuff84) = 'xy'
extra85 = 'stop'

# line 87
def func88():
    # comment
    return 90
91 92 93 94 95 96 97 98

# line 92
def f():
    class X:
        def g():
            "doc"
            return 42
    return X
99
method_in_dynamic_class = f().g
100 101 102 103 104 105 106 107

#line 101
def keyworded(*arg1, arg2=1):
    pass

#line 105
def annotated(arg1: list):
    pass
108 109 110 111

#line 109
def keyword_only_arg(*, arg):
    pass
112

113 114 115 116 117 118 119 120
@wrap(lambda: None)
def func114():
    return 115

class ClassWithMethod:
    def method(self):
        pass

121 122 123 124 125 126 127 128
from functools import wraps

def decorator(func):
    @wraps(func)
    def fake():
        return 42
    return fake

129
#line 129
130 131 132
@decorator
def real():
    return 20
133 134 135 136 137 138 139

#line 134
class cls135:
    def func136():
        def func137():
            never_reached1
            never_reached2