1# cython: binding=True, language_level=3 2# mode: run 3# tag: cyfunction 4 5import inspect 6 7try: 8 sig = inspect.Signature.from_callable 9except AttributeError: 10 sig = inspect.Signature.from_function 11 12 13def signatures_match(f1, f2): 14 if sig(f1) == sig(f2): 15 return None # nothing to show in doctest 16 return sig(f1), sig(f2) 17 18 19def b(a, b, c): 20 """ 21 >>> def py_b(a, b, c): pass 22 >>> signatures_match(b, py_b) 23 """ 24 25 26def c(a, b, c=1): 27 """ 28 >>> def py_c(a, b, c=1): pass 29 >>> signatures_match(c, py_c) 30 """ 31 32 33def d(a, b, *, c = 88): 34 """ 35 >>> def py_d(a, b, *, c = 88): pass 36 >>> signatures_match(d, py_d) 37 """ 38 39 40def e(a, b, c = 88, **kwds): 41 """ 42 >>> def py_e(a, b, c = 88, **kwds): pass 43 >>> signatures_match(e, py_e) 44 """ 45 46 47def f(a, b, *, c, d = 42): 48 """ 49 >>> def py_f(a, b, *, c, d = 42): pass 50 >>> signatures_match(f, py_f) 51 """ 52 53 54def g(a, b, *, c, d = 42, e = 17, f, **kwds): 55 """ 56 >>> def py_g(a, b, *, c, d = 42, e = 17, f, **kwds): pass 57 >>> signatures_match(g, py_g) 58 """ 59 60 61def h(a, b, *args, c, d = 42, e = 17, f, **kwds): 62 """ 63 >>> def py_h(a, b, *args, c, d = 42, e = 17, f, **kwds): pass 64 >>> signatures_match(h, py_h) 65 """ 66 67 68def k(a, b, c=1, *args, d = 42, e = 17, f, **kwds): 69 """ 70 >>> def py_k(a, b, c=1, *args, d = 42, e = 17, f, **kwds): pass 71 >>> signatures_match(k, py_k) 72 """ 73 74 75def l(*, a, b, c = 88): 76 """ 77 >>> def py_l(*, a, b, c = 88): pass 78 >>> signatures_match(l, py_l) 79 """ 80 81 82def m(a, *, b, c = 88): 83 """ 84 >>> def py_m(a, *, b, c = 88): pass 85 >>> signatures_match(m, py_m) 86 """ 87 a, b, c = b, c, a 88 89 90def n(a, *, b, c = 88): 91 """ 92 >>> def py_n(a, *, b, c = 88): pass 93 >>> signatures_match(n, py_n) 94 """ 95 96 97cpdef cp1(a, b): 98 """ 99 >>> def py_cp1(a, b): pass 100 >>> signatures_match(cp1, py_cp1) 101 """ 102 103 104# Currently broken, see GH #1864 105cpdef cp2(a, b=True): 106 """ 107 >>> def py_cp2(a, b=True): pass 108 109 #>>> signatures_match(cp2, py_cp2) 110 """ 111 112 113# Currently broken, see GH #1864 114cpdef cp3(a=1, b=True): 115 """ 116 >>> def py_cp3(a=1, b=True): pass 117 118 #>>> signatures_match(cp3, py_cp3) 119 """ 120