4
4
5
5
from abc import abstractmethod
6
6
import asyncio
7
- from collections .abc import Collection , Coroutine , Iterable
7
+ from collections .abc import Callable , Collection , Coroutine , Iterable
8
8
import dataclasses
9
9
from dataclasses import dataclass , field
10
10
from enum import Enum , auto
37
37
38
38
_LOGGER = logging .getLogger (__name__ )
39
39
type _SlotsType = dict [str , Any ]
40
+ type _IntentSlotsType = dict [
41
+ str | tuple [str , str ], VolSchemaType | Callable [[Any ], Any ]
42
+ ]
40
43
41
44
INTENT_TURN_OFF = "HassTurnOff"
42
45
INTENT_TURN_ON = "HassTurnOn"
@@ -808,8 +811,8 @@ def __init__(
808
811
self ,
809
812
intent_type : str ,
810
813
speech : str | None = None ,
811
- required_slots : dict [ str | tuple [ str , str ], VolSchemaType ] | None = None ,
812
- optional_slots : dict [ str | tuple [ str , str ], VolSchemaType ] | None = None ,
814
+ required_slots : _IntentSlotsType | None = None ,
815
+ optional_slots : _IntentSlotsType | None = None ,
813
816
required_domains : set [str ] | None = None ,
814
817
required_features : int | None = None ,
815
818
required_states : set [str ] | None = None ,
@@ -825,7 +828,7 @@ def __init__(
825
828
self .description = description
826
829
self .platforms = platforms
827
830
828
- self .required_slots : dict [ tuple [ str , str ], VolSchemaType ] = {}
831
+ self .required_slots : _IntentSlotsType = {}
829
832
if required_slots :
830
833
for key , value_schema in required_slots .items ():
831
834
if isinstance (key , str ):
@@ -834,7 +837,7 @@ def __init__(
834
837
835
838
self .required_slots [key ] = value_schema
836
839
837
- self .optional_slots : dict [ tuple [ str , str ], VolSchemaType ] = {}
840
+ self .optional_slots : _IntentSlotsType = {}
838
841
if optional_slots :
839
842
for key , value_schema in optional_slots .items ():
840
843
if isinstance (key , str ):
@@ -1108,8 +1111,8 @@ def __init__(
1108
1111
domain : str ,
1109
1112
service : str ,
1110
1113
speech : str | None = None ,
1111
- required_slots : dict [ str | tuple [ str , str ], VolSchemaType ] | None = None ,
1112
- optional_slots : dict [ str | tuple [ str , str ], VolSchemaType ] | None = None ,
1114
+ required_slots : _IntentSlotsType | None = None ,
1115
+ optional_slots : _IntentSlotsType | None = None ,
1113
1116
required_domains : set [str ] | None = None ,
1114
1117
required_features : int | None = None ,
1115
1118
required_states : set [str ] | None = None ,
0 commit comments