mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Improve intent schema typing (#120442)
This commit is contained in:
parent
b393024acd
commit
185e79fa1b
@ -33,6 +33,7 @@ from . import (
|
|||||||
entity_registry,
|
entity_registry,
|
||||||
floor_registry,
|
floor_registry,
|
||||||
)
|
)
|
||||||
|
from .typing import VolSchemaType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
type _SlotsType = dict[str, Any]
|
type _SlotsType = dict[str, Any]
|
||||||
@ -807,8 +808,8 @@ class DynamicServiceIntentHandler(IntentHandler):
|
|||||||
self,
|
self,
|
||||||
intent_type: str,
|
intent_type: str,
|
||||||
speech: str | None = None,
|
speech: str | None = None,
|
||||||
required_slots: dict[str | tuple[str, str], vol.Schema] | None = None,
|
required_slots: dict[str | tuple[str, str], VolSchemaType] | None = None,
|
||||||
optional_slots: dict[str | tuple[str, str], vol.Schema] | None = None,
|
optional_slots: dict[str | tuple[str, str], VolSchemaType] | None = None,
|
||||||
required_domains: set[str] | None = None,
|
required_domains: set[str] | None = None,
|
||||||
required_features: int | None = None,
|
required_features: int | None = None,
|
||||||
required_states: set[str] | None = None,
|
required_states: set[str] | None = None,
|
||||||
@ -824,7 +825,7 @@ class DynamicServiceIntentHandler(IntentHandler):
|
|||||||
self.description = description
|
self.description = description
|
||||||
self.platforms = platforms
|
self.platforms = platforms
|
||||||
|
|
||||||
self.required_slots: dict[tuple[str, str], vol.Schema] = {}
|
self.required_slots: dict[tuple[str, str], VolSchemaType] = {}
|
||||||
if required_slots:
|
if required_slots:
|
||||||
for key, value_schema in required_slots.items():
|
for key, value_schema in required_slots.items():
|
||||||
if isinstance(key, str):
|
if isinstance(key, str):
|
||||||
@ -833,7 +834,7 @@ class DynamicServiceIntentHandler(IntentHandler):
|
|||||||
|
|
||||||
self.required_slots[key] = value_schema
|
self.required_slots[key] = value_schema
|
||||||
|
|
||||||
self.optional_slots: dict[tuple[str, str], vol.Schema] = {}
|
self.optional_slots: dict[tuple[str, str], VolSchemaType] = {}
|
||||||
if optional_slots:
|
if optional_slots:
|
||||||
for key, value_schema in optional_slots.items():
|
for key, value_schema in optional_slots.items():
|
||||||
if isinstance(key, str):
|
if isinstance(key, str):
|
||||||
@ -1107,8 +1108,8 @@ class ServiceIntentHandler(DynamicServiceIntentHandler):
|
|||||||
domain: str,
|
domain: str,
|
||||||
service: str,
|
service: str,
|
||||||
speech: str | None = None,
|
speech: str | None = None,
|
||||||
required_slots: dict[str | tuple[str, str], vol.Schema] | None = None,
|
required_slots: dict[str | tuple[str, str], VolSchemaType] | None = None,
|
||||||
optional_slots: dict[str | tuple[str, str], vol.Schema] | None = None,
|
optional_slots: dict[str | tuple[str, str], VolSchemaType] | None = None,
|
||||||
required_domains: set[str] | None = None,
|
required_domains: set[str] | None = None,
|
||||||
required_features: int | None = None,
|
required_features: int | None = None,
|
||||||
required_states: set[str] | None = None,
|
required_states: set[str] | None = None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user