Support **dict expansion at resolved method call sites#676
Merged
Conversation
Python code often builds a parameter dictionary and passes it to a method call using **, e.g. client.start_job_run(**params). When the target method had a known signature (via pyspec), the translator would fail with 'method called with unknown keyword arguments: []'. Detect **dict at call sites of resolved methods and expand the dictionary into individual arguments: required params use DictStrAny_get, optional params use a new prelude function DictStrAny_get_or_none.
MikaelMayer
commented
Mar 26, 2026
Address review comment: DictStrAny_get_param with isOptional=false produces the same call, so the standalone helper is dead code. The transparent procedure handling for **dict expansion mirrors the existing non-**dict path (returns .Hole for opt_firstarg). Fixing this for both paths requires separate investigation.
This comment was marked as resolved.
This comment was marked as resolved.
Address review: the **dict path now handles transparent procedures (pyspec with precondition assertions) the same way as the named-kwargs path. This required switching from DictStrAny_get to Any_get/Any_get_or_none which operate on Any-typed variables. Added Any_get_or_none to the prelude: extracts a dict value by key, returning None if the key is absent.
Deduplicate the Name/Attribute dispatch logic between the **dict expansion path and the named-kwargs path.
MikaelMayer
commented
Mar 26, 2026
shigoel
previously approved these changes
Mar 26, 2026
joscoh
previously approved these changes
Mar 26, 2026
joscoh
approved these changes
Mar 26, 2026
shigoel
approved these changes
Mar 26, 2026
olivier-aws
pushed a commit
that referenced
this pull request
Mar 30, 2026
Support `**dict` expansion at resolved method call sites Python code often builds a parameter dictionary and passes it to a method call using `**`, e.g. `client.start_job_run(**params)`. When the target method had a known signature (via pyspec), the translator would fail with `'method' called with unknown keyword arguments: []` because it couldn't match the unnamed `**` keyword to individual named parameters. This PR detects `**dict` at call sites of resolved methods and expands the dictionary into individual arguments: required parameters use `DictStrAny_get` (preserving the precondition that the key must exist), and optional parameters use a new prelude function `DictStrAny_get_or_none` (returns `None` if the key is absent). Two end-to-end tests were added to the dispatch test suite: one covering all-required parameters, one covering a mix of required and optional parameters where the dictionary omits the optional keys. All existing tests continue to pass.
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.
Support
**dictexpansion at resolved method call sitesPython code often builds a parameter dictionary and passes it to a method
call using
**, e.g.client.start_job_run(**params). When the targetmethod had a known signature (via pyspec), the translator would fail with
'method' called with unknown keyword arguments: []because it couldn'tmatch the unnamed
**keyword to individual named parameters.This PR detects
**dictat call sites of resolved methods and expands thedictionary into individual arguments: required parameters use
DictStrAny_get(preserving the precondition that the key must exist), andoptional parameters use a new prelude function
DictStrAny_get_or_none(returns
Noneif the key is absent).Two end-to-end tests were added to the dispatch test suite: one covering
all-required parameters, one covering a mix of required and optional
parameters where the dictionary omits the optional keys. All existing tests
continue to pass.