Repository navigation
Call positional-only parameters positionally, by name (#14) - #33
Merged
Merged
Conversation
…#14, #13) call_with_inputs binds JSON keys that name positional-only parameters of the target (dict.__getitem__, __setitem__, def f(x, /)) and passes them positionally; a missing required one is an InputError (400). Used by attribute dispatch and by plain-function handlers. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…mes; constructors too Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…'t read their signature Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Oct 13, 2026
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.
Fixes #14. Also resolves the root cause of #13 (same
attr(**kwargs)call), but #13 reports a gunicorn worker timeout I did not reproduce, so I leave #13 open with a comment.py2http.util.call_with_inputs(func, args, kwargs)callsfunc(*args, **kwargs), but passes entries ofkwargsthat name positional-only parameters positionally (in declared order). A missing required one raisesInputError(400) instead of aTypeError(500). A callable with no readable signature is called exactly as before. It is used by_get_attr_value(object/module/class dispatch:dict.__getitem__,__setitem__) and by the two plain-function handlers (def f(x, /)). The protocol from the issue works as written:{"_attr_name": "__getitem__", "key": "some_key"}.Tests:
py2http/tests/test_positional_only.py(unit, plus end-to-end WSGI for a dict endpoint and a plain function); suite 120 pass (109 before).Adversarial review (fresh Opus subagent): requested changes; confirmed and fixed in the second commit, each with a test:
**kwargsand an optional positional-only parameter (Counter.update(iterable=None, /, **kwds),UserDict.update) used to receive a same-named JSON key as a keyword; it was now rebound positionally ({"_attr_name":"update","other":1}gave 500 instead of 200). Now, with**kwargsin the signature, only required positional-only parameters are bound by name.cls(**kwargs); they now go throughcall_with_inputstoo.Not changed:
inspect.signatureruns per request (about 15 to 115 microseconds), minor next to HTTP overhead. No new exposure: the attribute policy is untouched.🤖 Generated with Claude Code