Repository navigation
Stubs: accept a list of entity ids for a service's entity_id (#814) - #904
Merged
craigbarratt merged 1 commit intoNov 20, 2026
Merged
craigbarratt merged 1 commit into
craigbarratt merged 1 commit into
Conversation
…ents#814) The static service functions in the generated stubs typed the implicit entity_id argument as str, but a service target takes one entity id or a list of them, so passing a list was flagged by type checkers. Type it as str | list[str]. Signed-off-by: Sean Stoube <31805425+HoneyBearTech@users.noreply.github.com>
entity_id (#814)
craigbarratt
approved these changes
Nov 20, 2026
craigbarratt
left a comment
Member
There was a problem hiding this comment.
Thanks @HoneyBearTech, this looks good, and thanks for working through the other items in #814.
A small note on tuples: HA 2026.11's validators now accept a tuple (or even a set) of entity ids. Older versions don't, so str | list[str] is still the right type.
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.
Refs #814 (fixes item 2 only)
What was wrong
In the generated stubs, the implicit
entity_idargument of service functions was typedstr. A service target takes one entity id or a list of them, so type checkers flagged codethat passed a list, which works fine.
What I changed
In
stubs/generator.py, the implicitentity_idis now typedstr | list[str]. I updated the two matching checks intests/test_stubs.py.I left out
tuple[str]on purpose. Home Assistant'scomp_entity_idstreats a tuple as a single item, so a tuple of ids wouldn't work as expected.The other items in #814
duration): the stubs don't type thedurationselector at all, so the type isn't too narrow.input_numberasConvertibleToFloat): the issue itself leaves the right design open, so I didn't change it.delay_secs,hold_secs): alreadyfloat, because their selector uses a fractional step.webhook_methodsdefault,event_trigger'sstr_expr): already correct on master.color_name): a tidy-up rather than a wrong type, so I didn't change it here.Testing
tests/test_stubs.py, the full test suite, pylint, mypy and ruff all pass on Python 3.14.