mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Add voluptuous type aliases (#120399)
This commit is contained in:
parent
53f5dec1b4
commit
b4eee166aa
@ -96,7 +96,7 @@ from .helpers.deprecation import (
|
||||
dir_with_deprecated_constants,
|
||||
)
|
||||
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.async_ import (
|
||||
cancelling,
|
||||
@ -2355,7 +2355,7 @@ class Service:
|
||||
| EntityServiceResponse
|
||||
| None,
|
||||
],
|
||||
schema: vol.Schema | None,
|
||||
schema: VolSchemaType | None,
|
||||
domain: str,
|
||||
service: str,
|
||||
context: Context | None = None,
|
||||
@ -2503,7 +2503,7 @@ class ServiceRegistry:
|
||||
| EntityServiceResponse
|
||||
| None,
|
||||
],
|
||||
schema: vol.Schema | None = None,
|
||||
schema: VolSchemaType | None = None,
|
||||
supports_response: SupportsResponse = SupportsResponse.NONE,
|
||||
job_type: HassJobType | None = None,
|
||||
) -> None:
|
||||
@ -2530,7 +2530,7 @@ class ServiceRegistry:
|
||||
| EntityServiceResponse
|
||||
| None,
|
||||
],
|
||||
schema: vol.Schema | None = None,
|
||||
schema: VolSchemaType | None = None,
|
||||
supports_response: SupportsResponse = SupportsResponse.NONE,
|
||||
job_type: HassJobType | None = None,
|
||||
) -> None:
|
||||
|
@ -11,7 +11,6 @@ from types import ModuleType
|
||||
from typing import Any, Generic
|
||||
|
||||
from typing_extensions import TypeVar
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config as conf_util
|
||||
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 .entity_platform import EntityPlatform
|
||||
from .typing import ConfigType, DiscoveryInfoType
|
||||
from .typing import ConfigType, DiscoveryInfoType, VolDictType, VolSchemaType
|
||||
|
||||
DEFAULT_SCAN_INTERVAL = timedelta(seconds=15)
|
||||
DATA_INSTANCES = "entity_components"
|
||||
@ -222,7 +221,7 @@ class EntityComponent(Generic[_EntityT]):
|
||||
def async_register_legacy_entity_service(
|
||||
self,
|
||||
name: str,
|
||||
schema: dict[str | vol.Marker, Any] | vol.Schema,
|
||||
schema: VolDictType | VolSchemaType,
|
||||
func: str | Callable[..., Any],
|
||||
required_features: list[int] | None = None,
|
||||
supports_response: SupportsResponse = SupportsResponse.NONE,
|
||||
@ -259,7 +258,7 @@ class EntityComponent(Generic[_EntityT]):
|
||||
def async_register_entity_service(
|
||||
self,
|
||||
name: str,
|
||||
schema: dict[str | vol.Marker, Any] | vol.Schema,
|
||||
schema: VolDictType | VolSchemaType,
|
||||
func: str | Callable[..., Any],
|
||||
required_features: list[int] | None = None,
|
||||
supports_response: SupportsResponse = SupportsResponse.NONE,
|
||||
|
@ -10,8 +10,6 @@ from functools import partial
|
||||
from logging import Logger, getLogger
|
||||
from typing import TYPE_CHECKING, Any, Protocol
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import (
|
||||
ATTR_RESTORED,
|
||||
@ -52,7 +50,7 @@ from . import (
|
||||
from .entity_registry import EntityRegistry, RegistryEntryDisabler, RegistryEntryHider
|
||||
from .event import async_call_later
|
||||
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:
|
||||
from .entity import Entity
|
||||
@ -987,7 +985,7 @@ class EntityPlatform:
|
||||
def async_register_entity_service(
|
||||
self,
|
||||
name: str,
|
||||
schema: dict[str | vol.Marker, Any] | vol.Schema,
|
||||
schema: VolDictType | VolSchemaType,
|
||||
func: str | Callable[..., Any],
|
||||
required_features: Iterable[int] | None = None,
|
||||
supports_response: SupportsResponse = SupportsResponse.NONE,
|
||||
|
@ -5,6 +5,8 @@ from enum import Enum
|
||||
from functools import partial
|
||||
from typing import Any, Never
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from .deprecation import (
|
||||
DeferredDeprecatedAlias,
|
||||
all_with_deprecated_constants,
|
||||
@ -19,6 +21,8 @@ type ServiceDataType = dict[str, Any]
|
||||
type StateType = str | int | float | None
|
||||
type TemplateVarsType = Mapping[str, Any] | None
|
||||
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
|
||||
type QueryType = Any
|
||||
|
Loading…
x
Reference in New Issue
Block a user