Skip to content

Stubs: flatten all service field sections, annotate multiple selectors as lists - #878

Open
jeyrb wants to merge 1 commit into
custom-components:masterfrom
jeyrb:stubs-sections-and-multiple
Open

jeyrb wants to merge 1 commit into
custom-components:masterfrom
jeyrb:stubs-sections-and-multiple

Conversation

@jeyrb

@jeyrb jeyrb commented Oct 8, 2026 •

Copy link
Copy Markdown

I encountered this when trying to make sure Supernotify worked well with Pyscript.

It has its own notify action now, which is much richer than the plain vanilla notify.send_message style to be easier to use from the actions UI. So a more complicated services.yaml, though other integrations might similarly be pushing what the configflow UI can do.

Problem

pyscript.generate_stubs gets the signature wrong for services whose services.yaml uses sections or multiple selectors.

  • Sections. fix stub generator dropping additional_fields entries #867 flattened the sections named additional_fields and advanced_fields, but a section can have any name. Any other section becomes a bogus untyped parameter, and the fields inside it are dropped.
  • multiple: true. A text, select or entity selector with multiple: true takes a list, but is annotated as a single value, so passing a list is reported as a type error.

For example, a service with a multimedia section and a multiple text field currently generates:

def notify(*, message: str | None=None, delivery: str | None=None, multimedia=None): ...

Change

  • A field is treated as a section when it has fields and no selector, whatever its name.
  • A selector with multiple: true is annotated as list[...] of its usual type.

The same service now generates:

def notify(*, message: str | None=None, delivery: list[str] | None=None, camera_entity_id: str | None=None, snapshot_url: str | None=None): ...

Testing

Added test_stubs_flatten_named_sections_and_multiple, which fails on master and passes with this change. The existing stub tests still pass.

…s as lists

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeyrb
jeyrb marked this pull request as ready for review October 8, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant