Remove invalidation_version from deprecated (#44156)
* Remove invalidation_version from deprecated. We don't follow up and just hurts releases * Revert change to ZHApull/44175/head
parent
c02be99ab7
commit
17cd00ba83
|
@ -23,7 +23,7 @@ from .const import (
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.115")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
||||
async def _await_cancel(task):
|
||||
|
|
|
@ -32,7 +32,7 @@ from .helpers import async_get_blueprints
|
|||
_CONDITION_SCHEMA = vol.All(cv.ensure_list, [cv.CONDITION_SCHEMA])
|
||||
|
||||
PLATFORM_SCHEMA = vol.All(
|
||||
cv.deprecated(CONF_HIDE_ENTITY, invalidation_version="0.110"),
|
||||
cv.deprecated(CONF_HIDE_ENTITY),
|
||||
script.make_script_schema(
|
||||
{
|
||||
# str on purpose
|
||||
|
|
|
@ -30,7 +30,7 @@ from .coordinator import CanaryDataUpdateCoordinator
|
|||
MIN_TIME_BETWEEN_SESSION_RENEW = timedelta(seconds=90)
|
||||
|
||||
PLATFORM_SCHEMA = vol.All(
|
||||
cv.deprecated(CONF_FFMPEG_ARGUMENTS, invalidation_version="0.118"),
|
||||
cv.deprecated(CONF_FFMPEG_ARGUMENTS),
|
||||
PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(
|
||||
|
|
|
@ -33,10 +33,10 @@ _LOGGER = logging.getLogger(__name__)
|
|||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.All(
|
||||
cv.deprecated(CONF_EMAIL, invalidation_version="0.119"),
|
||||
cv.deprecated(CONF_API_KEY, invalidation_version="0.119"),
|
||||
cv.deprecated(CONF_ZONE, invalidation_version="0.119"),
|
||||
cv.deprecated(CONF_RECORDS, invalidation_version="0.119"),
|
||||
cv.deprecated(CONF_EMAIL),
|
||||
cv.deprecated(CONF_API_KEY),
|
||||
cv.deprecated(CONF_ZONE),
|
||||
cv.deprecated(CONF_RECORDS),
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_EMAIL): cv.string,
|
||||
|
|
|
@ -30,7 +30,7 @@ COMPONENT_TYPES = ["climate", "sensor", "switch"]
|
|||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
vol.All(
|
||||
cv.deprecated(DOMAIN, invalidation_version="0.113.0"),
|
||||
cv.deprecated(DOMAIN),
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ from .const import (
|
|||
DOMAIN,
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.120")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = ["media_player", "remote"]
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
|
|
@ -20,7 +20,7 @@ from .const import (
|
|||
|
||||
DEFAULT_UPDATE_INTERVAL = timedelta(minutes=30)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.119")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
|
||||
|
|
|
@ -80,13 +80,13 @@ SUPPORT_HYPERION = SUPPORT_COLOR | SUPPORT_BRIGHTNESS | SUPPORT_EFFECT
|
|||
|
||||
# Usage of YAML for configuration of the Hyperion component is deprecated.
|
||||
PLATFORM_SCHEMA = vol.All(
|
||||
cv.deprecated(CONF_HDMI_PRIORITY, invalidation_version="0.118"),
|
||||
cv.deprecated(CONF_HDMI_PRIORITY),
|
||||
cv.deprecated(CONF_HOST),
|
||||
cv.deprecated(CONF_PORT),
|
||||
cv.deprecated(CONF_DEFAULT_COLOR, invalidation_version="0.118"),
|
||||
cv.deprecated(CONF_DEFAULT_COLOR),
|
||||
cv.deprecated(CONF_NAME),
|
||||
cv.deprecated(CONF_PRIORITY),
|
||||
cv.deprecated(CONF_EFFECT_LIST, invalidation_version="0.118"),
|
||||
cv.deprecated(CONF_EFFECT_LIST),
|
||||
PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
|
|
|
@ -11,7 +11,7 @@ from .const import DOMAIN, PLATFORM
|
|||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.All(
|
||||
cv.deprecated(CONF_NAME, invalidation_version="0.110"),
|
||||
cv.deprecated(CONF_NAME),
|
||||
vol.Schema({vol.Optional(CONF_NAME, default=DOMAIN): cv.string}),
|
||||
)
|
||||
},
|
||||
|
|
|
@ -191,7 +191,7 @@ def embedded_broker_deprecated(value):
|
|||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.All(
|
||||
cv.deprecated(CONF_TLS_VERSION, invalidation_version="0.115"),
|
||||
cv.deprecated(CONF_TLS_VERSION),
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_CLIENT_ID): cv.string,
|
||||
|
|
|
@ -30,7 +30,7 @@ ATTR_SYSTEM_NAME = "system_name"
|
|||
DEFAULT_ATTRIBUTION = "Data provided by Notion"
|
||||
DEFAULT_SCAN_INTERVAL = timedelta(minutes=1)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.119")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
||||
|
|
|
@ -74,7 +74,7 @@ SERVICE_STOP_PROGRAM_SCHEMA = vol.Schema(
|
|||
|
||||
SERVICE_STOP_ZONE_SCHEMA = vol.Schema({vol.Required(CONF_ZONE_ID): cv.positive_int})
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.119")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = ["binary_sensor", "sensor", "switch"]
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ from .const import (
|
|||
DOMAIN,
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.120")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = [MEDIA_PLAYER_DOMAIN, REMOTE_DOMAIN]
|
||||
SCAN_INTERVAL = timedelta(seconds=15)
|
||||
|
|
|
@ -33,7 +33,7 @@ from .const import (
|
|||
ENTITY_COMPONENTS,
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.117")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
||||
LOGGER_INFO_REGEX = re.compile(r"^(\w+)\.?(\w+)?\.?(\w+)?\.?(\w+)?(?:\..*)?$")
|
||||
|
|
|
@ -138,7 +138,7 @@ SERVICE_SET_SYSTEM_PROPERTIES_SCHEMA = SERVICE_BASE_SCHEMA.extend(
|
|||
}
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.119")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
||||
@callback
|
||||
|
|
|
@ -40,7 +40,7 @@ DOMAIN = const.DOMAIN
|
|||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.All(
|
||||
cv.deprecated(const.CONF_PROFILES, invalidation_version="0.114"),
|
||||
cv.deprecated(const.CONF_PROFILES),
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_CLIENT_ID): vol.All(cv.string, vol.Length(min=1)),
|
||||
|
|
|
@ -254,8 +254,10 @@ class ZHADevice(LogMixin):
|
|||
"device_event_type": "device_offline"
|
||||
}
|
||||
}
|
||||
|
||||
if hasattr(self._zigpy_device, "device_automation_triggers"):
|
||||
triggers.update(self._zigpy_device.device_automation_triggers)
|
||||
|
||||
return triggers
|
||||
|
||||
@property
|
||||
|
|
|
@ -28,7 +28,6 @@ from typing import (
|
|||
from urllib.parse import urlparse
|
||||
from uuid import UUID
|
||||
|
||||
from pkg_resources import parse_version
|
||||
import voluptuous as vol
|
||||
import voluptuous_serialize
|
||||
|
||||
|
@ -80,7 +79,6 @@ from homeassistant.const import (
|
|||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
WEEKDAYS,
|
||||
__version__,
|
||||
)
|
||||
from homeassistant.core import split_entity_id, valid_entity_id
|
||||
from homeassistant.exceptions import TemplateError
|
||||
|
@ -712,7 +710,6 @@ class multi_select:
|
|||
def deprecated(
|
||||
key: str,
|
||||
replacement_key: Optional[str] = None,
|
||||
invalidation_version: Optional[str] = None,
|
||||
default: Optional[Any] = None,
|
||||
) -> Callable[[Dict], Dict]:
|
||||
"""
|
||||
|
@ -725,8 +722,6 @@ def deprecated(
|
|||
- No warning if only replacement_key provided
|
||||
- No warning if neither key nor replacement_key are provided
|
||||
- Adds replacement_key with default value in this case
|
||||
- Once the invalidation_version is crossed, raises vol.Invalid if key
|
||||
is detected
|
||||
"""
|
||||
module = inspect.getmodule(inspect.stack()[1][0])
|
||||
if module is not None:
|
||||
|
@ -737,56 +732,24 @@ def deprecated(
|
|||
# https://github.com/home-assistant/core/issues/24982
|
||||
module_name = __name__
|
||||
|
||||
if replacement_key and invalidation_version:
|
||||
warning = (
|
||||
"The '{key}' option is deprecated,"
|
||||
" please replace it with '{replacement_key}'."
|
||||
" This option {invalidation_status} invalid in version"
|
||||
" {invalidation_version}"
|
||||
)
|
||||
elif replacement_key:
|
||||
if replacement_key:
|
||||
warning = (
|
||||
"The '{key}' option is deprecated,"
|
||||
" please replace it with '{replacement_key}'"
|
||||
)
|
||||
elif invalidation_version:
|
||||
warning = (
|
||||
"The '{key}' option is deprecated,"
|
||||
" please remove it from your configuration."
|
||||
" This option {invalidation_status} invalid in version"
|
||||
" {invalidation_version}"
|
||||
)
|
||||
else:
|
||||
warning = (
|
||||
"The '{key}' option is deprecated,"
|
||||
" please remove it from your configuration"
|
||||
)
|
||||
|
||||
def check_for_invalid_version() -> None:
|
||||
"""Raise error if current version has reached invalidation."""
|
||||
if not invalidation_version:
|
||||
return
|
||||
|
||||
if parse_version(__version__) >= parse_version(invalidation_version):
|
||||
raise vol.Invalid(
|
||||
warning.format(
|
||||
key=key,
|
||||
replacement_key=replacement_key,
|
||||
invalidation_status="became",
|
||||
invalidation_version=invalidation_version,
|
||||
)
|
||||
)
|
||||
|
||||
def validator(config: Dict) -> Dict:
|
||||
"""Check if key is in config and log warning."""
|
||||
if key in config:
|
||||
check_for_invalid_version()
|
||||
KeywordStyleAdapter(logging.getLogger(module_name)).warning(
|
||||
warning,
|
||||
key=key,
|
||||
replacement_key=replacement_key,
|
||||
invalidation_status="will become",
|
||||
invalidation_version=invalidation_version,
|
||||
)
|
||||
|
||||
value = config[key]
|
||||
|
|
|
@ -698,116 +698,6 @@ def test_deprecated_with_replacement_key(caplog, schema):
|
|||
assert test_data == output
|
||||
|
||||
|
||||
def test_deprecated_with_invalidation_version(caplog, schema, version):
|
||||
"""
|
||||
Test deprecation behaves correctly with only an invalidation_version.
|
||||
|
||||
Expected behavior:
|
||||
- Outputs the appropriate deprecation warning if key is detected
|
||||
- Processes schema without changing any values
|
||||
- No warning or difference in output if key is not provided
|
||||
- Once the invalidation_version is crossed, raises vol.Invalid if key
|
||||
is detected
|
||||
"""
|
||||
deprecated_schema = vol.All(
|
||||
cv.deprecated("mars", invalidation_version="9999.99.9"), schema
|
||||
)
|
||||
|
||||
message = (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please remove it from your configuration. "
|
||||
"This option will become invalid in version 9999.99.9"
|
||||
)
|
||||
|
||||
test_data = {"mars": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 1
|
||||
assert message in caplog.text
|
||||
assert test_data == output
|
||||
|
||||
caplog.clear()
|
||||
assert len(caplog.records) == 0
|
||||
|
||||
test_data = {"venus": False}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
invalidated_schema = vol.All(
|
||||
cv.deprecated("mars", invalidation_version="0.1.0"), schema
|
||||
)
|
||||
test_data = {"mars": True}
|
||||
with pytest.raises(vol.MultipleInvalid) as exc_info:
|
||||
invalidated_schema(test_data)
|
||||
assert str(exc_info.value) == (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please remove it from your configuration. This option became "
|
||||
"invalid in version 0.1.0"
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_with_replacement_key_and_invalidation_version(
|
||||
caplog, schema, version
|
||||
):
|
||||
"""
|
||||
Test deprecation behaves with a replacement key & invalidation_version.
|
||||
|
||||
Expected behavior:
|
||||
- Outputs the appropriate deprecation warning if key is detected
|
||||
- Processes schema moving the value from key to replacement_key
|
||||
- Processes schema changing nothing if only replacement_key provided
|
||||
- No warning if only replacement_key provided
|
||||
- No warning or difference in output if neither key nor
|
||||
replacement_key are provided
|
||||
- Once the invalidation_version is crossed, raises vol.Invalid if key
|
||||
is detected
|
||||
"""
|
||||
deprecated_schema = vol.All(
|
||||
cv.deprecated(
|
||||
"mars", replacement_key="jupiter", invalidation_version="9999.99.9"
|
||||
),
|
||||
schema,
|
||||
)
|
||||
|
||||
warning = (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option will become "
|
||||
"invalid in version 9999.99.9"
|
||||
)
|
||||
|
||||
test_data = {"mars": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 1
|
||||
assert warning in caplog.text
|
||||
assert {"jupiter": True} == output
|
||||
|
||||
caplog.clear()
|
||||
assert len(caplog.records) == 0
|
||||
|
||||
test_data = {"jupiter": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
test_data = {"venus": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
invalidated_schema = vol.All(
|
||||
cv.deprecated("mars", replacement_key="jupiter", invalidation_version="0.1.0"),
|
||||
schema,
|
||||
)
|
||||
test_data = {"mars": True}
|
||||
with pytest.raises(vol.MultipleInvalid) as exc_info:
|
||||
invalidated_schema(test_data)
|
||||
assert str(exc_info.value) == (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option became "
|
||||
"invalid in version 0.1.0"
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_with_default(caplog, schema):
|
||||
"""
|
||||
Test deprecation behaves correctly with a default value.
|
||||
|
@ -894,69 +784,6 @@ def test_deprecated_with_replacement_key_and_default(caplog, schema):
|
|||
assert {"jupiter": True} == output
|
||||
|
||||
|
||||
def test_deprecated_with_replacement_key_invalidation_version_default(
|
||||
caplog, schema, version
|
||||
):
|
||||
"""
|
||||
Test deprecation with a replacement key, invalidation_version & default.
|
||||
|
||||
Expected behavior:
|
||||
- Outputs the appropriate deprecation warning if key is detected
|
||||
- Processes schema moving the value from key to replacement_key
|
||||
- Processes schema changing nothing if only replacement_key provided
|
||||
- No warning if only replacement_key provided
|
||||
- No warning if neither key nor replacement_key are provided
|
||||
- Adds replacement_key with default value in this case
|
||||
- Once the invalidation_version is crossed, raises vol.Invalid if key
|
||||
is detected
|
||||
"""
|
||||
deprecated_schema = vol.All(
|
||||
cv.deprecated(
|
||||
"mars",
|
||||
replacement_key="jupiter",
|
||||
invalidation_version="9999.99.9",
|
||||
default=False,
|
||||
),
|
||||
schema,
|
||||
)
|
||||
|
||||
test_data = {"mars": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 1
|
||||
assert (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option will become "
|
||||
"invalid in version 9999.99.9"
|
||||
) in caplog.text
|
||||
assert {"jupiter": True} == output
|
||||
|
||||
caplog.clear()
|
||||
assert len(caplog.records) == 0
|
||||
|
||||
test_data = {"jupiter": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
test_data = {"venus": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert {"venus": True, "jupiter": False} == output
|
||||
|
||||
invalidated_schema = vol.All(
|
||||
cv.deprecated("mars", replacement_key="jupiter", invalidation_version="0.1.0"),
|
||||
schema,
|
||||
)
|
||||
test_data = {"mars": True}
|
||||
with pytest.raises(vol.MultipleInvalid) as exc_info:
|
||||
invalidated_schema(test_data)
|
||||
assert str(exc_info.value) == (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option became "
|
||||
"invalid in version 0.1.0"
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_cant_find_module():
|
||||
"""Test if the current module cannot be inspected."""
|
||||
with patch("inspect.getmodule", return_value=None):
|
||||
|
@ -964,7 +791,6 @@ def test_deprecated_cant_find_module():
|
|||
cv.deprecated(
|
||||
"mars",
|
||||
replacement_key="jupiter",
|
||||
invalidation_version="1.0.0",
|
||||
default=False,
|
||||
)
|
||||
|
||||
|
|
|
@ -1116,7 +1116,7 @@ async def test_component_config_exceptions(hass, caplog):
|
|||
("non_existing", vol.Schema({"zone": int}), None),
|
||||
("zone", vol.Schema({}), None),
|
||||
("plex", vol.Schema(vol.All({"plex": {"host": str}})), "dict"),
|
||||
("openuv", cv.deprecated("openuv", invalidation_version="0.115"), None),
|
||||
("openuv", cv.deprecated("openuv"), None),
|
||||
],
|
||||
)
|
||||
def test_identify_config_schema(domain, schema, expected):
|
||||
|
|
Loading…
Reference in New Issue