From 594e905742c6e934f17eb4c7ad94053ed0dc946e Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 12 Dec 2020 22:24:16 +0100 Subject: [PATCH] Remove invalidation_version from deprecated (#44156) * Remove invalidation_version from deprecated. We don't follow up and just hurts releases * Revert change to ZHA --- .../components/arcam_fmj/__init__.py | 2 +- homeassistant/components/automation/config.py | 2 +- homeassistant/components/canary/camera.py | 2 +- .../components/cloudflare/__init__.py | 8 +- homeassistant/components/daikin/__init__.py | 2 +- homeassistant/components/directv/__init__.py | 2 +- .../components/flunearyou/__init__.py | 2 +- homeassistant/components/hyperion/light.py | 6 +- homeassistant/components/local_ip/__init__.py | 2 +- homeassistant/components/mqtt/__init__.py | 2 +- homeassistant/components/notion/__init__.py | 2 +- .../components/rainmachine/__init__.py | 2 +- homeassistant/components/roku/__init__.py | 2 +- homeassistant/components/sentry/__init__.py | 2 +- .../components/simplisafe/__init__.py | 2 +- homeassistant/components/withings/__init__.py | 2 +- homeassistant/components/zha/core/device.py | 2 + homeassistant/helpers/config_validation.py | 39 +--- tests/helpers/test_config_validation.py | 174 ------------------ tests/test_config.py | 2 +- 20 files changed, 25 insertions(+), 234 deletions(-) diff --git a/homeassistant/components/arcam_fmj/__init__.py b/homeassistant/components/arcam_fmj/__init__.py index 0875e094352..0175dfd6586 100644 --- a/homeassistant/components/arcam_fmj/__init__.py +++ b/homeassistant/components/arcam_fmj/__init__.py @@ -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): diff --git a/homeassistant/components/automation/config.py b/homeassistant/components/automation/config.py index 8a13334bc6d..9c26f3552aa 100644 --- a/homeassistant/components/automation/config.py +++ b/homeassistant/components/automation/config.py @@ -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 diff --git a/homeassistant/components/canary/camera.py b/homeassistant/components/canary/camera.py index c3fd2a6ff00..fd2f08c1488 100644 --- a/homeassistant/components/canary/camera.py +++ b/homeassistant/components/canary/camera.py @@ -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( diff --git a/homeassistant/components/cloudflare/__init__.py b/homeassistant/components/cloudflare/__init__.py index 3ebb919393a..446890887c1 100644 --- a/homeassistant/components/cloudflare/__init__.py +++ b/homeassistant/components/cloudflare/__init__.py @@ -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, diff --git a/homeassistant/components/daikin/__init__.py b/homeassistant/components/daikin/__init__.py index 7b9c1ded673..b4950b8b05b 100644 --- a/homeassistant/components/daikin/__init__.py +++ b/homeassistant/components/daikin/__init__.py @@ -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( { diff --git a/homeassistant/components/directv/__init__.py b/homeassistant/components/directv/__init__.py index 59682178d40..22a97b9e82e 100644 --- a/homeassistant/components/directv/__init__.py +++ b/homeassistant/components/directv/__init__.py @@ -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) diff --git a/homeassistant/components/flunearyou/__init__.py b/homeassistant/components/flunearyou/__init__.py index 7399dd3847d..46442f112b6 100644 --- a/homeassistant/components/flunearyou/__init__.py +++ b/homeassistant/components/flunearyou/__init__.py @@ -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"] diff --git a/homeassistant/components/hyperion/light.py b/homeassistant/components/hyperion/light.py index b8e9040f7ce..5aa087c0515 100644 --- a/homeassistant/components/hyperion/light.py +++ b/homeassistant/components/hyperion/light.py @@ -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, diff --git a/homeassistant/components/local_ip/__init__.py b/homeassistant/components/local_ip/__init__.py index f787c028762..637520aa30c 100644 --- a/homeassistant/components/local_ip/__init__.py +++ b/homeassistant/components/local_ip/__init__.py @@ -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}), ) }, diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 73caf023ef6..cced3670cca 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -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, diff --git a/homeassistant/components/notion/__init__.py b/homeassistant/components/notion/__init__.py index 561f3edf896..88da19f5ab2 100644 --- a/homeassistant/components/notion/__init__.py +++ b/homeassistant/components/notion/__init__.py @@ -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: diff --git a/homeassistant/components/rainmachine/__init__.py b/homeassistant/components/rainmachine/__init__.py index a520772ff77..41c56e38db6 100644 --- a/homeassistant/components/rainmachine/__init__.py +++ b/homeassistant/components/rainmachine/__init__.py @@ -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"] diff --git a/homeassistant/components/roku/__init__.py b/homeassistant/components/roku/__init__.py index 739e345a637..af2e0ee946f 100644 --- a/homeassistant/components/roku/__init__.py +++ b/homeassistant/components/roku/__init__.py @@ -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) diff --git a/homeassistant/components/sentry/__init__.py b/homeassistant/components/sentry/__init__.py index eecac0281e6..6be02b9ba5e 100644 --- a/homeassistant/components/sentry/__init__.py +++ b/homeassistant/components/sentry/__init__.py @@ -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+)?(?:\..*)?$") diff --git a/homeassistant/components/simplisafe/__init__.py b/homeassistant/components/simplisafe/__init__.py index 2430aad43cf..89f5c40b1ff 100644 --- a/homeassistant/components/simplisafe/__init__.py +++ b/homeassistant/components/simplisafe/__init__.py @@ -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 diff --git a/homeassistant/components/withings/__init__.py b/homeassistant/components/withings/__init__.py index 94795a10c83..c6f420d172a 100644 --- a/homeassistant/components/withings/__init__.py +++ b/homeassistant/components/withings/__init__.py @@ -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)), diff --git a/homeassistant/components/zha/core/device.py b/homeassistant/components/zha/core/device.py index 81b522308ff..cd3b1bd93ce 100644 --- a/homeassistant/components/zha/core/device.py +++ b/homeassistant/components/zha/core/device.py @@ -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 diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index dea8deec715..0513c5c6e7e 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -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] diff --git a/tests/helpers/test_config_validation.py b/tests/helpers/test_config_validation.py index 480b2280afe..5d907408b61 100644 --- a/tests/helpers/test_config_validation.py +++ b/tests/helpers/test_config_validation.py @@ -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, ) diff --git a/tests/test_config.py b/tests/test_config.py index bfda156f2b7..931b672d01b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -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):