fix: tuple_the_args binds to its own signature; all_pk_signature keeps a forced keyword-only; replace_kwargs_using drops a source *args - #96
Merged
Conversation
…only in all_pk_signature; drop a source *args in replace_kwargs_using - ch_variadics_to_non_variadic_kind (tuple_the_args): the wrapper now binds the call to the signature it advertises (Sig.map_arguments) and rebuilds the call to the original function with _args_and_kwargs_from_all_pk_arguments. The tupled param can be given by keyword, defaults skipped before it are filled, and the variadic keyword can be given by name as a dict. Calls the advertised signature rejects raise FuncCallNotMatchingSignature instead of being silently dropped or mangled. Removes the dead try/except on the signature. - all_pk_signature: a required keyword-only param after a param with a default stays keyword-only, and so does everything after it, instead of raising. ch_func_to_all_pk therefore handles `def h(x, *y, z)` -> `(x, y=(), *, z)`. - replace_kwargs_using: a source VAR_POSITIONAL is no longer injected as a required keyword-only param the target could never forward. Closes #78 Closes #93
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves the two design questions left open by #92, decided with a use-site inventory across i2's 102 local dependents and an independent adversarial review. The decisions, options and evidence are on the issues: #78 and #93.
Changes (all in
i2/signatures.py)ch_variadics_to_non_variadic_kind/tuple_the_args(tuple_the_args: passing the tupled *args by keyword fails, and ch_func_to_all_pk can't handle a required keyword-only after *args #93 part 1): the wrapper binds the call to the signature it advertises (Sig.map_arguments) and rebuilds the call to the original function with_args_and_kwargs_from_all_pk_arguments(the helper Cloud sweep: fix ch_func_to_all_pk with *args, partialx reordering, pyproject + uv CI, runnable README #92 added, now shared). The tupled param can be given by keyword, defaults skipped before it are filled, and a variadic keyword given by name as a dict is spread. Calls the advertised signature rejects raiseFuncCallNotMatchingSignature(aTypeError). On 0.1.74 eventuple_the_args(lambda a, b=1, *args: ...)(1)raisedIndexError.all_pk_signature(tuple_the_args: passing the tupled *args by keyword fails, and ch_func_to_all_pk can't handle a required keyword-only after *args #93 part 2): a required keyword-only param after a param with a default stays keyword-only, and so does everything after it (and after an untupled*args), instead of the constructor raising.ch_func_to_all_pk(lambda x, *y, z: ...)is now(x, y=(), *, z).replace_kwargs_using(Changereplace_kwargs_usingso it will create keyword-only params for wrapped variadic #78): a source*argsis no longer injected as a required keyword-only param the target could never forward.Behaviour changes, deliberate, for direct
tuple_the_argsusers only: an unknown keyword for a function without**kwargsnow raises instead of being silently dropped; a by-namekwargs={...}dict is spread instead of silently dropped.Tests
DAGwith nodes shapedf(x, *y, z)andg(a, *args, **kw)builds and runs; both crashed at construction before.*argsrule), one filed as ch_func_to_all_pk: unify the excess-keyword policy of the with-*args and without-*args paths #95.Closes #78
Closes #93
https://claude.ai/code/session_01MCpYkDGuVEygBHheTCcURV