Add voluptuous type aliases (#120399)
This commit is contained in:
parent
53f5dec1b4
commit
b4eee166aa
4 changed files with 13 additions and 12 deletions
|
@ -96,7 +96,7 @@ from .helpers.deprecation import (
|
||||||
dir_with_deprecated_constants,
|
dir_with_deprecated_constants,
|
||||||
)
|
)
|
||||||
from .helpers.json import json_bytes, json_fragment
|
from .helpers.json import json_bytes, json_fragment
|
||||||
from .helpers.typing import UNDEFINED, UndefinedType
|
from .helpers.typing import UNDEFINED, UndefinedType, VolSchemaType
|
||||||
from .util import dt as dt_util, location
|
from .util import dt as dt_util, location
|
||||||
from .util.async_ import (
|
from .util.async_ import (
|
||||||
cancelling,
|
cancelling,
|
||||||
|
@ -2355,7 +2355,7 @@ class Service:
|
||||||
| EntityServiceResponse
|
| EntityServiceResponse
|
||||||
| None,
|
| None,
|
||||||
],
|
],
|
||||||
schema: vol.Schema | None,
|
schema: VolSchemaType | None,
|
||||||
domain: str,
|
domain: str,
|
||||||
service: str,
|
service: str,
|
||||||
context: Context | None = None,
|
context: Context | None = None,
|
||||||
|
@ -2503,7 +2503,7 @@ class ServiceRegistry:
|
||||||
| EntityServiceResponse
|
| EntityServiceResponse
|
||||||
| None,
|
| None,
|
||||||
],
|
],
|
||||||
schema: vol.Schema | None = None,
|
schema: VolSchemaType | None = None,
|
||||||
supports_response: SupportsResponse = SupportsResponse.NONE,
|
supports_response: SupportsResponse = SupportsResponse.NONE,
|
||||||
job_type: HassJobType | None = None,
|
job_type: HassJobType | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -2530,7 +2530,7 @@ class ServiceRegistry:
|
||||||
| EntityServiceResponse
|
| EntityServiceResponse
|
||||||
| None,
|
| None,
|
||||||
],
|
],
|
||||||
schema: vol.Schema | None = None,
|
schema: VolSchemaType | None = None,
|
||||||
supports_response: SupportsResponse = SupportsResponse.NONE,
|
supports_response: SupportsResponse = SupportsResponse.NONE,
|
||||||
job_type: HassJobType | None = None,
|
job_type: HassJobType | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
@ -11,7 +11,6 @@ from types import ModuleType
|
||||||
from typing import Any, Generic
|
from typing import Any, Generic
|
||||||
|
|
||||||
from typing_extensions import TypeVar
|
from typing_extensions import TypeVar
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant import config as conf_util
|
from homeassistant import config as conf_util
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -36,7 +35,7 @@ from homeassistant.setup import async_prepare_setup_platform
|
||||||
|
|
||||||
from . import config_validation as cv, discovery, entity, service
|
from . import config_validation as cv, discovery, entity, service
|
||||||
from .entity_platform import EntityPlatform
|
from .entity_platform import EntityPlatform
|
||||||
from .typing import ConfigType, DiscoveryInfoType
|
from .typing import ConfigType, DiscoveryInfoType, VolDictType, VolSchemaType
|
||||||
|
|
||||||
DEFAULT_SCAN_INTERVAL = timedelta(seconds=15)
|
DEFAULT_SCAN_INTERVAL = timedelta(seconds=15)
|
||||||
DATA_INSTANCES = "entity_components"
|
DATA_INSTANCES = "entity_components"
|
||||||
|
@ -222,7 +221,7 @@ class EntityComponent(Generic[_EntityT]):
|
||||||
def async_register_legacy_entity_service(
|
def async_register_legacy_entity_service(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
schema: dict[str | vol.Marker, Any] | vol.Schema,
|
schema: VolDictType | VolSchemaType,
|
||||||
func: str | Callable[..., Any],
|
func: str | Callable[..., Any],
|
||||||
required_features: list[int] | None = None,
|
required_features: list[int] | None = None,
|
||||||
supports_response: SupportsResponse = SupportsResponse.NONE,
|
supports_response: SupportsResponse = SupportsResponse.NONE,
|
||||||
|
@ -259,7 +258,7 @@ class EntityComponent(Generic[_EntityT]):
|
||||||
def async_register_entity_service(
|
def async_register_entity_service(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
schema: dict[str | vol.Marker, Any] | vol.Schema,
|
schema: VolDictType | VolSchemaType,
|
||||||
func: str | Callable[..., Any],
|
func: str | Callable[..., Any],
|
||||||
required_features: list[int] | None = None,
|
required_features: list[int] | None = None,
|
||||||
supports_response: SupportsResponse = SupportsResponse.NONE,
|
supports_response: SupportsResponse = SupportsResponse.NONE,
|
||||||
|
|
|
@ -10,8 +10,6 @@ from functools import partial
|
||||||
from logging import Logger, getLogger
|
from logging import Logger, getLogger
|
||||||
from typing import TYPE_CHECKING, Any, Protocol
|
from typing import TYPE_CHECKING, Any, Protocol
|
||||||
|
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_RESTORED,
|
ATTR_RESTORED,
|
||||||
|
@ -52,7 +50,7 @@ from . import (
|
||||||
from .entity_registry import EntityRegistry, RegistryEntryDisabler, RegistryEntryHider
|
from .entity_registry import EntityRegistry, RegistryEntryDisabler, RegistryEntryHider
|
||||||
from .event import async_call_later
|
from .event import async_call_later
|
||||||
from .issue_registry import IssueSeverity, async_create_issue
|
from .issue_registry import IssueSeverity, async_create_issue
|
||||||
from .typing import UNDEFINED, ConfigType, DiscoveryInfoType
|
from .typing import UNDEFINED, ConfigType, DiscoveryInfoType, VolDictType, VolSchemaType
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .entity import Entity
|
from .entity import Entity
|
||||||
|
@ -987,7 +985,7 @@ class EntityPlatform:
|
||||||
def async_register_entity_service(
|
def async_register_entity_service(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
schema: dict[str | vol.Marker, Any] | vol.Schema,
|
schema: VolDictType | VolSchemaType,
|
||||||
func: str | Callable[..., Any],
|
func: str | Callable[..., Any],
|
||||||
required_features: Iterable[int] | None = None,
|
required_features: Iterable[int] | None = None,
|
||||||
supports_response: SupportsResponse = SupportsResponse.NONE,
|
supports_response: SupportsResponse = SupportsResponse.NONE,
|
||||||
|
|
|
@ -5,6 +5,8 @@ from enum import Enum
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from typing import Any, Never
|
from typing import Any, Never
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
from .deprecation import (
|
from .deprecation import (
|
||||||
DeferredDeprecatedAlias,
|
DeferredDeprecatedAlias,
|
||||||
all_with_deprecated_constants,
|
all_with_deprecated_constants,
|
||||||
|
@ -19,6 +21,8 @@ type ServiceDataType = dict[str, Any]
|
||||||
type StateType = str | int | float | None
|
type StateType = str | int | float | None
|
||||||
type TemplateVarsType = Mapping[str, Any] | None
|
type TemplateVarsType = Mapping[str, Any] | None
|
||||||
type NoEventData = Mapping[str, Never]
|
type NoEventData = Mapping[str, Never]
|
||||||
|
type VolSchemaType = vol.Schema | vol.All | vol.Any
|
||||||
|
type VolDictType = dict[str | vol.Marker, Any]
|
||||||
|
|
||||||
# Custom type for recorder Queries
|
# Custom type for recorder Queries
|
||||||
type QueryType = Any
|
type QueryType = Any
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue