Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion custom_components/pyscript/stubs/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ async def _create_service_function(
field_nodes = [
_ServiceField(
name="entity_id",
annotation=self._name("str"),
# a service target takes one entity id or a list of them
annotation=ast.parse("str | list[str]", mode="eval").body,
required=True,
default=None,
description="Entity ID",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async def fake_service_descriptions(_hass: HomeAssistant) -> dict[str, dict[str,
assert "class _light_state(StateVal)" in generated_content
assert "lamp: _light_state" in generated_content
assert "def blink(self, *, brightness: int, speed" in generated_content
assert "def blink(*, entity_id: str, brightness: int, speed:" in generated_content
assert "def blink(*, entity_id: str | list[str], brightness: int, speed:" in generated_content
assert "Blink the light once." in generated_content
assert "Literal" in generated_content
assert "'slow'" in generated_content
Expand Down Expand Up @@ -464,7 +464,7 @@ async def fake_service_descriptions(_hass: HomeAssistant) -> dict[str, dict[str,
assert send["footer"] == ("str | None", "None")
# ...a field named like the implicit target argument is skipped...
assert send_to == {
"entity_id": ("str", None),
"entity_id": ("str | list[str]", None),
"blocking": ("bool", "..."),
"return_response": ("bool", "..."),
}
Expand Down
Loading