summaryrefslogtreecommitdiff
path: root/tests/run/py34_signature.pyx
blob: 14780ff7b490ae775b0c33887b251b752869c1e5 (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
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
# cython: binding=True, language_level=3
# mode: run
# tag: cyfunction

import inspect

try:
    sig = inspect.Signature.from_callable
except AttributeError:
    sig = inspect.Signature.from_function


def signatures_match(f1, f2):
    if sig(f1) == sig(f2):
        return None  # nothing to show in doctest
    return sig(f1), sig(f2)


def b(a, b, c):
    """
    >>> def py_b(a, b, c): pass
    >>> signatures_match(b, py_b)
    """


def c(a, b, c=1):
    """
    >>> def py_c(a, b, c=1): pass
    >>> signatures_match(c, py_c)
    """


def d(a, b, *, c = 88):
    """
    >>> def py_d(a, b, *, c = 88): pass
    >>> signatures_match(d, py_d)
    """


def e(a, b, c = 88, **kwds):
    """
    >>> def py_e(a, b, c = 88, **kwds): pass
    >>> signatures_match(e, py_e)
    """


def f(a, b, *, c, d = 42):
    """
    >>> def py_f(a, b, *, c, d = 42): pass
    >>> signatures_match(f, py_f)
    """


def g(a, b, *, c, d = 42, e = 17, f, **kwds):
    """
    >>> def py_g(a, b, *, c, d = 42, e = 17, f, **kwds): pass
    >>> signatures_match(g, py_g)
    """


def h(a, b, *args, c, d = 42, e = 17, f, **kwds):
    """
    >>> def py_h(a, b, *args, c, d = 42, e = 17, f, **kwds): pass
    >>> signatures_match(h, py_h)
    """


def k(a, b, c=1, *args, d = 42, e = 17, f, **kwds):
    """
    >>> def py_k(a, b, c=1, *args, d = 42, e = 17, f, **kwds): pass
    >>> signatures_match(k, py_k)
    """


def l(*, a, b, c = 88):
    """
    >>> def py_l(*, a, b, c = 88): pass
    >>> signatures_match(l, py_l)
    """


def m(a, *, b, c = 88):
    """
    >>> def py_m(a, *, b, c = 88): pass
    >>> signatures_match(m, py_m)
    """
    a, b, c = b, c, a


def n(a, *, b, c = 88):
    """
    >>> def py_n(a, *, b, c = 88): pass
    >>> signatures_match(n, py_n)
    """


cpdef cp1(a, b):
    """
    >>> def py_cp1(a, b): pass
    >>> signatures_match(cp1, py_cp1)
    """


cpdef cp2(a, b=True):
    """
    >>> def py_cp2(a, b=True): pass

    >>> signatures_match(cp2, py_cp2)
    """


cpdef cp3(a=1, b=True):
    """
    >>> def py_cp3(a=1, b=True): pass

    >>> signatures_match(cp3, py_cp3)
    """