20
>>> i_called_directly(4)
22
>>> i_called_directly.HERE
27
def __init__(self, func):
30
def __call__(self, *args, **kwargs):
31
return self.func(*args, **kwargs)
36
except AttributeError:
60
def decorate(self, func):
70
def i_called_directly(x):
71
# PEP 614 means this now works
74
list_of_decorators = [decorate, decorate2]
77
def test_index_from_decorator_list0(a, b):
79
PEP 614 means this now works
80
>>> test_index_from_decorator_list0(1, 2)
82
>>> test_index_from_decorator_list0.HERE
87
@list_of_decorators[1](1,2)
88
def test_index_from_decorator_list1(a, b):
90
PEP 614 means this now works
91
>>> test_index_from_decorator_list1(1, 2)
93
>>> test_index_from_decorator_list1.HERE
98
def append_to_list_decorator(lst):
99
def do_append_to_list_dec(func):
103
return do_append_to_list_dec
105
def outer(arg1, arg2):
107
ensure decorators are analysed in the correct scope
108
https://github.com/cython/cython/issues/4367
109
mainly intended as a compile-time test (but it does run...)
110
>>> outer(append_to_list_decorator, [1,2,3])
113
@arg1([x for x in arg2])
118
class HasProperty(object):
120
>>> hp = HasProperty()
127
def __init__(self) -> None:
131
def value(self) -> int:
134
# https://github.com/cython/cython/issues/4836
135
# The variable tracker was confusing "value" in the decorator
136
# for "value" in the argument list
138
def value(self, value: int):