You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Careful reordering when adding keyword-only params to a list that already has a variadic keyword. #17
Hypothesis: Somewhere in the process, the parameters should probably be loosely reordered. We don't want to allow complete reordering, but just enough to allow variadics to be in their proper place (the keyword arguments before the kwargs.
Still reproduces on master (70125c02), same fundamental error (now raised from i2.wrapper.move_params_to_the_end -> include_exclude -> Sig.__getitem__ -> Sig.from_params, which builds a plain inspect.Signature from reordered params without re-validating/re-sorting variadic-keyword-vs-keyword-only ordering):
```python
from i2 import partialx
@partialx(partialx, x=2, _allow_reordering=True)
def foo(x, y, z=0):
return x + y * z
ValueError: wrong parameter order: variadic keyword parameter before keyword-only parameter
```
Root cause looks to be in i2/wrapper.py::move_params_to_the_end (calls include_exclude -> include_exclude_ingress_factory -> Ingress(inner_sig=sig, outer_sig=sig[include], ...)), where sig[include] re-orders params but doesn't guarantee the "keyword-only params before **kwargs" invariant inspect.Signature requires. Related: Sig.__getitem__/Sig.from_params also silently drops the return annotation on re-indexing (found while fixing #48, #88) -- these two are probably worth fixing together as a Sig.__getitem__ hardening pass, since several other issues touch the same code path. Leaving as a plan item; not attempting a fix here given the surface area (any change to Sig.__getitem__'s reordering affects most of the wrapper/deco module).
Activity
thorwhalen commentedon Sep 22, 2026
Still reproduces on master (
70125c02), same fundamental error (now raised fromi2.wrapper.move_params_to_the_end->include_exclude->Sig.__getitem__->Sig.from_params, which builds a plaininspect.Signaturefrom reordered params without re-validating/re-sorting variadic-keyword-vs-keyword-only ordering):```python
from i2 import partialx
@partialx(partialx, x=2, _allow_reordering=True)
def foo(x, y, z=0):
return x + y * z
ValueError: wrong parameter order: variadic keyword parameter before keyword-only parameter
```
Root cause looks to be in
i2/wrapper.py::move_params_to_the_end(callsinclude_exclude->include_exclude_ingress_factory->Ingress(inner_sig=sig, outer_sig=sig[include], ...)), wheresig[include]re-orders params but doesn't guarantee the "keyword-only params before**kwargs" invariantinspect.Signaturerequires. Related:Sig.__getitem__/Sig.from_paramsalso silently drops the return annotation on re-indexing (found while fixing #48, #88) -- these two are probably worth fixing together as aSig.__getitem__hardening pass, since several other issues touch the same code path. Leaving as a plan item; not attempting a fix here given the surface area (any change toSig.__getitem__'s reordering affects most of the wrapper/deco module).fix: keep parameter kinds in order when partialx reorders params
fix: keep parameter kinds in order when partialx reorders params
fix: keep parameter kinds in order when partialx reorders params