Add import aliases for PLATFORM_SCHEMA (#120445)

pull/120451/head
Marc Mueller 2024-06-25 19:16:19 +02:00 committed by GitHub
parent cbcf29720d
commit 3559755aed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 35 additions and 30 deletions

View File

@ -18,7 +18,7 @@ from homeassistant.components.notify import (
ATTR_DATA,
ATTR_TARGET,
ATTR_TITLE,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA as NOTIFY_PLATFORM_SCHEMA,
BaseNotificationService,
)
from homeassistant.const import CONTENT_TYPE_JSON
@ -36,7 +36,7 @@ ATTR_ASB_TARGET = "target"
PLATFORM_SCHEMA = vol.All(
cv.has_at_least_one_key(CONF_QUEUE_NAME, CONF_TOPIC_NAME),
PLATFORM_SCHEMA.extend(
NOTIFY_PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_CONNECTION_STRING): cv.string,
vol.Exclusive(

View File

@ -9,7 +9,7 @@ from serial import SerialException
import voluptuous as vol
from homeassistant.components.media_player import (
PLATFORM_SCHEMA,
PLATFORM_SCHEMA as MEDIA_PLAYER_PLATFORM_SCHEMA,
MediaPlayerEntity,
MediaPlayerEntityFeature,
MediaPlayerState,
@ -56,7 +56,7 @@ SOURCE_IDS = vol.All(vol.Coerce(int), vol.Range(min=1, max=8))
PLATFORM_SCHEMA = vol.All(
cv.has_at_least_one_key(CONF_PORT, CONF_HOST),
PLATFORM_SCHEMA.extend(
MEDIA_PLAYER_PLATFORM_SCHEMA.extend(
{
vol.Exclusive(CONF_PORT, CONF_TYPE): cv.string,
vol.Exclusive(CONF_HOST, CONF_TYPE): cv.string,

View File

@ -10,7 +10,7 @@ from broadlink.exceptions import BroadlinkException
import voluptuous as vol
from homeassistant.components.switch import (
PLATFORM_SCHEMA,
PLATFORM_SCHEMA as SWITCH_PLATFORM_SCHEMA,
SwitchDeviceClass,
SwitchEntity,
)
@ -56,7 +56,7 @@ PLATFORM_SCHEMA = vol.All(
cv.deprecated(CONF_SLOTS),
cv.deprecated(CONF_TIMEOUT),
cv.deprecated(CONF_TYPE),
PLATFORM_SCHEMA.extend(
SWITCH_PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_MAC): mac_address,
vol.Optional(CONF_HOST): cv.string,

View File

@ -11,7 +11,7 @@ import voluptuous as vol
from homeassistant.components.sensor import (
ENTITY_ID_FORMAT,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA,
SensorEntity,
)
from homeassistant.const import (
@ -73,7 +73,7 @@ CITYBIKES_NETWORKS = "citybikes_networks"
PLATFORM_SCHEMA = vol.All(
cv.has_at_least_one_key(CONF_RADIUS, CONF_STATIONS_LIST),
PLATFORM_SCHEMA.extend(
SENSOR_PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_NAME, default=""): cv.string,
vol.Optional(CONF_NETWORK): cv.string,

View File

@ -9,7 +9,7 @@ from typing import Any
import voluptuous as vol
from homeassistant.components.sensor import (
PLATFORM_SCHEMA,
PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA,
SensorDeviceClass,
SensorEntity,
SensorStateClass,
@ -66,7 +66,7 @@ def exactly_two_period_keys[_T: dict[str, Any]](conf: _T) -> _T:
PLATFORM_SCHEMA = vol.All(
PLATFORM_SCHEMA.extend(
SENSOR_PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_ENTITY_ID): cv.entity_id,
vol.Required(CONF_STATE): vol.All(cv.ensure_list, [cv.string]),

View File

@ -14,7 +14,7 @@ import voluptuous as vol
from homeassistant.components.sensor import (
DEVICE_CLASS_UNITS,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA,
RestoreSensor,
SensorDeviceClass,
SensorExtraStoredData,
@ -81,7 +81,7 @@ DEFAULT_ROUND = 3
PLATFORM_SCHEMA = vol.All(
cv.removed(CONF_UNIT_OF_MEASUREMENT),
PLATFORM_SCHEMA.extend(
SENSOR_PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_NAME): cv.string,
vol.Optional(CONF_UNIQUE_ID): cv.string,

View File

@ -10,7 +10,7 @@ import voluptuous as vol
from homeassistant.components.binary_sensor import (
DOMAIN as BINARY_SENSOR_DOMAIN,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA as BINARY_SENSOR_PLATFORM_SCHEMA,
BinarySensorEntity,
)
from homeassistant.const import (
@ -44,10 +44,9 @@ from .schema import BINARY_SENSOR_SCHEMA, RESOURCE_SCHEMA
_LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({**RESOURCE_SCHEMA, **BINARY_SENSOR_SCHEMA})
PLATFORM_SCHEMA = vol.All(
cv.has_at_least_one_key(CONF_RESOURCE, CONF_RESOURCE_TEMPLATE), PLATFORM_SCHEMA
BINARY_SENSOR_PLATFORM_SCHEMA.extend({**RESOURCE_SCHEMA, **BINARY_SENSOR_SCHEMA}),
cv.has_at_least_one_key(CONF_RESOURCE, CONF_RESOURCE_TEMPLATE),
)
TRIGGER_ENTITY_OPTIONS = (

View File

@ -12,7 +12,7 @@ import voluptuous as vol
from homeassistant.components.sensor import (
CONF_STATE_CLASS,
DOMAIN as SENSOR_DOMAIN,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA,
SensorDeviceClass,
)
from homeassistant.components.sensor.helpers import async_parse_date_datetime
@ -49,10 +49,9 @@ from .util import parse_json_attributes
_LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({**RESOURCE_SCHEMA, **SENSOR_SCHEMA})
PLATFORM_SCHEMA = vol.All(
cv.has_at_least_one_key(CONF_RESOURCE, CONF_RESOURCE_TEMPLATE), PLATFORM_SCHEMA
SENSOR_PLATFORM_SCHEMA.extend({**RESOURCE_SCHEMA, **SENSOR_SCHEMA}),
cv.has_at_least_one_key(CONF_RESOURCE, CONF_RESOURCE_TEMPLATE),
)
TRIGGER_ENTITY_OPTIONS = (

View File

@ -17,7 +17,7 @@ from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAI
from homeassistant.components.recorder import get_instance, history
from homeassistant.components.sensor import (
DEVICE_CLASS_STATE_CLASSES,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA,
SensorDeviceClass,
SensorEntity,
SensorStateClass,
@ -229,7 +229,7 @@ def valid_keep_last_sample(config: dict[str, Any]) -> dict[str, Any]:
return config
_PLATFORM_SCHEMA_BASE = PLATFORM_SCHEMA.extend(
_PLATFORM_SCHEMA_BASE = SENSOR_PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_ENTITY_ID): cv.entity_id,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,

View File

@ -34,7 +34,9 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import TemplateError
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA
from homeassistant.helpers.config_validation import (
PLATFORM_SCHEMA as BASE_PLATFORM_SCHEMA,
)
from homeassistant.helpers.entity import async_generate_entity_id
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.script import Script
@ -115,7 +117,7 @@ PLATFORM_SCHEMA = vol.All(
# CONF_WHITE_VALUE_* is deprecated, support will be removed in release 2022.9
cv.removed(CONF_WHITE_VALUE_ACTION),
cv.removed(CONF_WHITE_VALUE_TEMPLATE),
PLATFORM_SCHEMA.extend(
BASE_PLATFORM_SCHEMA.extend(
{vol.Required(CONF_LIGHTS): cv.schema_with_slug_keys(LIGHT_SCHEMA)}
),
)

View File

@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
DEVICE_CLASSES_SCHEMA,
DOMAIN as SENSOR_DOMAIN,
ENTITY_ID_FORMAT,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA,
RestoreSensor,
SensorDeviceClass,
SensorEntity,
@ -152,7 +152,7 @@ def rewrite_legacy_to_modern_conf(cfg: dict[str, dict]) -> list[dict]:
PLATFORM_SCHEMA = vol.All(
PLATFORM_SCHEMA.extend(
SENSOR_PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_TRIGGER): cv.match_all, # to raise custom warning
vol.Required(CONF_SENSORS): cv.schema_with_slug_keys(LEGACY_SENSOR_SCHEMA),

View File

@ -41,7 +41,9 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import TemplateError
from homeassistant.helpers import template
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA
from homeassistant.helpers.config_validation import (
PLATFORM_SCHEMA as BASE_PLATFORM_SCHEMA,
)
from homeassistant.helpers.entity import async_generate_entity_id
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import ExtraStoredData, RestoreEntity
@ -136,7 +138,7 @@ WEATHER_SCHEMA = vol.Schema(
PLATFORM_SCHEMA = vol.All(
cv.deprecated(CONF_FORECAST_TEMPLATE),
PLATFORM_SCHEMA.extend(WEATHER_SCHEMA.schema),
BASE_PLATFORM_SCHEMA.extend(WEATHER_SCHEMA.schema),
)

View File

@ -7,7 +7,10 @@ from typing import Any
import voluptuous as vol
from homeassistant.components.notify import PLATFORM_SCHEMA, BaseNotificationService
from homeassistant.components.notify import (
PLATFORM_SCHEMA as NOTIFY_PLATFORM_SCHEMA,
BaseNotificationService,
)
from homeassistant.const import ATTR_ENTITY_ID, CONF_ENTITY_ID, CONF_NAME
from homeassistant.core import HomeAssistant, split_entity_id
import homeassistant.helpers.config_validation as cv
@ -23,7 +26,7 @@ _LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = vol.All(
cv.has_at_least_one_key(CONF_TTS_SERVICE, CONF_ENTITY_ID),
PLATFORM_SCHEMA.extend(
NOTIFY_PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_NAME): cv.string,
vol.Exclusive(CONF_TTS_SERVICE, ENTITY_LEGACY_PROVIDER_GROUP): cv.entity_id,