-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Fix zero-argument functions with as_function #150062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in the as_function helper that prevented it from working with zero-argument functions. The issue was that the wrapper function incorrectly expected a required value parameter, making it impossible to call macros that don't need any arguments.
- Removes the required
valueparameter from theas_functionwrapper - Updates the macro call to not pass the removed
valueparameter - Adds test coverage for zero-argument function scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| homeassistant/helpers/template.py | Fixes the as_function wrapper to support zero-argument functions by removing the required value parameter |
| tests/helpers/test_template.py | Adds test case to verify as_function works correctly with zero-argument macros |
Comments suppressed due to low confidence (1)
tests/helpers/test_template.py:853
- [nitpick] The macro name
macro_get_hellois redundant since it's already a macro. Consider renaming to justget_hellofor clarity.
{%- macro macro_get_hello(returns) -%}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @depoll 👍
|
test failure unrelated |
Breaking change
Proposed change
Fixes an issue with
as_functionthat prevented it from working with 0-argument functions.Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: