typed argument convergance - #16134
Open
dcbaker wants to merge 52 commits into
Open
Conversation
This will eventually take over for both typed_kwargs and typed_pos_args, but for now it implements just the typed_kwarg info.
This makes the common case of the index working fast, and the case of it being wrong the exceptional case
dcbaker
force-pushed
the
submit/typed-args
branch
from
August 20, 2026 21:12
12da74a to
9c55028
Compare
As it is now unused!
This will allow TypedArgs to take the place of noPosargs
This is now covered by TypedArgs
dcbaker
force-pushed
the
submit/typed-args
branch
from
August 20, 2026 21:18
9c55028 to
b7087ba
Compare
dnicolodi
reviewed
Aug 21, 2026
bonzini
reviewed
Aug 24, 2026
| raise InvalidArguments(f'Array index {index} is out of bounds for array of size {len(self.held_object)}.') | ||
| return args[1] | ||
| return self.held_object[index] | ||
| index, fallback = args |
bonzini
reviewed
Aug 24, 2026
bonzini
left a comment
Contributor
There was a problem hiding this comment.
I would start by moving to a separate PR:
- everything up to interpreterbase: Refactor TypedArgs to make room for posargs
- interpreter/primitives/array: implement array as try/except
- possibly, some of the list->tuple fixes for positional arguments
| elif n == value: | ||
| warning = f'value "{n}"' | ||
| if warning: | ||
| feature.single_use(f'"{self.name}" positional argument "{index}" {warning}', version, subproject, msg, location=node) |
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.
We have a series of decorators that are used to check argument typing, one for positional arguments, one for keyword arguments, one for no positional arguments, and one for no keyword arguments.
This is annoying for a number of reasons.
To end that, I give you
TypedArgs, the one decorator to rule them all. It does the work oftyped_pos_args,typed_kwargs,noPosArgs, andnoKwArgs, in one decorator. It also reworks positional arguments to be more like keyword arguments, using special classes that describe the various kinds of positional arguments, and allowing more conversion and checking to be done at in the decorator than in the function body.Part of the goal is that this forces the developer to deal with all of the types, rather than just the positional or keyword arguments. Part of the goal is to make it easier to re-use pieces like with keyword arguments.
There is a significant LOC increase, most of this is in additional unit tests for new features, and not in the implementation, which ends up being roughly even.