Preserve positional-only signatures in funcutils wrappers - #511
Open
ZelinZhu-Richard wants to merge 1 commit into
Open
ZelinZhu-Richard wants to merge 1 commit into
ZelinZhu-Richard wants to merge 1 commit into
Conversation
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.
The change
Fixes #510. A wrapper around
def f(a, /, **kw)currently raisesTypeErrorfor the valid callf(1, a=2), because its generated signature loses/.Pass the existing positional-only metadata through the signature formatter and keep it synchronized when arguments are removed. The formatter gains an optional trailing
posonlyargsargument; invocation forwarding is unchanged. Tests cover keyword-name collisions, rejected keyword binding, defaults and annotations, mixed signatures, and injected argument removal.Validation:
git diff --checkpassed.test_wraps_posonly_keyword_collisionandtest_wraps_posonly_rejects_keyword_bindingcover keyword collisions and rejection of keyword binding to positional-only parameters.test_formatargspec_posonly_defaults_and_annotationsandtest_wraps_posonly_mixed_signaturecover defaults, annotations, variadic arguments, and generated signatures.test_FunctionBuilder_remove_posonly_argsandtest_wraps_injected_posonly_argcover argument removal and injection.New positional-only test definitions use guarded
exec, following the existing tests. Compatibility grammar checks passed; the full supported-interpreter matrix has not been run.AI assistance