Repository navigation
Fix keyword argument collisions in pyscript function calls - #926
Merged
craigbarratt merged 1 commit intoNov 24, 2026
Merged
craigbarratt merged 1 commit into
craigbarratt merged 1 commit into
Conversation
craigbarratt
left a comment
Member
There was a problem hiding this comment.
Thanks @dmamelin, nice fix. I also checked self=/ast_ctx= through a method with a renamed first parameter, a @classmethod, __init__, super().__init__(**kw) and a property setter, and they all work. Removing any one of the /s fails the new tests.
The task functions in trigger.py have the same problem. Could you fix them in this PR too, with a test for each?
task.create(echo, func=1)raisesTypeError: ... user_task_create() got multiple values for argument 'func'. Bothuser_task_create(func, ...)and its innerfunc_call(func, func_name, new_ast_ctx, ...)need a/.task.add_done_callback(task, callback, ...)collides ontask=andcallback=.task.executor(func, ...)collides onfunc=.
Contributor
Author
|
Thanks, I'm aware of these. #927 moves the |
Member
dmamelin
added a commit
to dmamelin/pyscript
that referenced
this pull request
Nov 24, 2026
…ional-only Follow-up to custom-components#926: keyword arguments such as func, task, callback, domain, name or event_type are now passed on to the called function, the service data or the event data, instead of clashing with the parameters of task.create, task.executor, task.add_done_callback, service.call and event.fire.
craigbarratt
pushed a commit
that referenced
this pull request
Nov 24, 2026
* move task.create, task.add_done_callback and task.executor to task_functions.py * remove legacy_decorators option * move time, state and task helpers out of trigger.py * remove legacy trigger plumbing and trigger.py * fix watchdog startup/shutdown event annotations * remove legacy event, mqtt and webhook modules * warn when unexpected kwargs are ignored because of TRIGGER_KWARGS * add mqtt to after_dependencies hassfest accepted the mqtt import only because of the legacy mqtt.py file, which it treated as an mqtt platform of pyscript. * make internal parameters of task.*, service.call and event.fire positional-only Follow-up to #926: keyword arguments such as func, task, callback, domain, name or event_type are now passed on to the called function, the service data or the event data, instead of clashing with the parameters of task.create, task.executor, task.add_done_callback, service.call and event.fire.
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.
Calling
echo(func=42)raisedTypeError: AstEval.call_func() got multiple values for argument 'func'beforeechoran. The evaluator passedechopositionally to its internalfuncparameter, then forwardedfunc=42to the same parameter.This change makes the evaluator’s internal parameters positional-only throughout the call chain. Scripts can now use
func,func_name,ast_ctx, andselfas keyword arguments. For example, this call now returns42:Regression tests cover the reported call and
**kwargsforwarding to functions and bound methods, including calls from@pyscript_compilecode. All 335 tests passed.