Found while fixing #12 (PR #92). Neither is fixed there, because both need a design call.
1. tuple_the_args rejects its own signature. The wrapper advertises the tupled *args as a positional-or-keyword param, but giving it by keyword fails:
from i2.signatures import tuple_the_args, Sig
def foo(*pos, **kws):
return pos, kws
f = tuple_the_args(foo)
Sig(f) # <Sig (pos=(), **kws)>
f((1, 2), a=3) # works
f(pos=(1, 2), a=3) # FuncCallNotMatchingSignature: There should be only keyword arguments after the Variadic args
The cause is in ch_variadics_to_non_variadic_kind's inner function. It rebuilds positional args with mk_args_and_kwargs on the original signature, which unpacks the tuple, then indexes args[idx_of_vp] expecting the tuple. A fix has to fill any skipped defaults before *args, e.g. def g(a, b=1, *args) called as tupled(1, args=(2, 3)) must become g(1, 1, 2, 3). PR #92 adds a helper for exactly that (_args_and_kwargs_from_all_pk_arguments in signatures.py), which could be reused here.
2. ch_func_to_all_pk fails at decoration time for a required keyword-only param after *args:
from i2.signatures import ch_func_to_all_pk
def h(x, *y, z):
...
ch_func_to_all_pk(h) # ValueError: non-default argument follows default argument
The all-PK signature would be (x, y=(), z), which isn't valid. The options are to drop y's default (making it required), to reorder, or to keep z keyword-only. Each changes what callers see, so this needs your decision.
Found while fixing #12 (PR #92). Neither is fixed there, because both need a design call.
1.
tuple_the_argsrejects its own signature. The wrapper advertises the tupled*argsas a positional-or-keyword param, but giving it by keyword fails:The cause is in
ch_variadics_to_non_variadic_kind's inner function. It rebuilds positional args withmk_args_and_kwargson the original signature, which unpacks the tuple, then indexesargs[idx_of_vp]expecting the tuple. A fix has to fill any skipped defaults before*args, e.g.def g(a, b=1, *args)called astupled(1, args=(2, 3))must becomeg(1, 1, 2, 3). PR #92 adds a helper for exactly that (_args_and_kwargs_from_all_pk_argumentsinsignatures.py), which could be reused here.2.
ch_func_to_all_pkfails at decoration time for a required keyword-only param after*args:The all-PK signature would be
(x, y=(), z), which isn't valid. The options are to dropy's default (making it required), to reorder, or to keepzkeyword-only. Each changes what callers see, so this needs your decision.