From 0e52d149e47d15db4d97c7693c95956ee65b914b Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 2 Jul 2024 21:57:09 +0200 Subject: [PATCH] Update voluptuous to 0.15.2 (#120631) * Update voluptuous to 0.15.1 * Fix typing issues * Add type ignores for json result type * Update voluptuous to 0.15.2 --------- Co-authored-by: J. Nick Koston --- homeassistant/components/auth/login_flow.py | 2 +- homeassistant/components/auth/mfa_setup_flow.py | 2 +- homeassistant/components/automation/config.py | 4 ++-- homeassistant/components/websocket_api/decorators.py | 2 +- homeassistant/config.py | 2 +- homeassistant/data_entry_flow.py | 6 ++---- homeassistant/helpers/data_entry_flow.py | 2 +- homeassistant/package_constraints.txt | 2 +- homeassistant/util/yaml/objects.py | 2 +- pyproject.toml | 2 +- requirements.txt | 2 +- 11 files changed, 13 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/auth/login_flow.py b/homeassistant/components/auth/login_flow.py index 5bad0dbb9998f4..3664c3ca5c919b 100644 --- a/homeassistant/components/auth/login_flow.py +++ b/homeassistant/components/auth/login_flow.py @@ -215,7 +215,7 @@ def _prepare_result_json( data = result.copy() if (schema := data["data_schema"]) is None: - data["data_schema"] = [] + data["data_schema"] = [] # type: ignore[typeddict-item] # json result type else: data["data_schema"] = voluptuous_serialize.convert(schema) diff --git a/homeassistant/components/auth/mfa_setup_flow.py b/homeassistant/components/auth/mfa_setup_flow.py index 35d87cafd4fe1f..8ae55396fa9a8f 100644 --- a/homeassistant/components/auth/mfa_setup_flow.py +++ b/homeassistant/components/auth/mfa_setup_flow.py @@ -156,7 +156,7 @@ def _prepare_result_json( data = result.copy() if (schema := data["data_schema"]) is None: - data["data_schema"] = [] + data["data_schema"] = [] # type: ignore[typeddict-item] # json result type else: data["data_schema"] = voluptuous_serialize.convert(schema) diff --git a/homeassistant/components/automation/config.py b/homeassistant/components/automation/config.py index 676aba946f4a5a..cc4e9aba7fbd76 100644 --- a/homeassistant/components/automation/config.py +++ b/homeassistant/components/automation/config.py @@ -5,7 +5,7 @@ from collections.abc import Mapping from contextlib import suppress from enum import StrEnum -from typing import Any, cast +from typing import Any import voluptuous as vol from voluptuous.humanize import humanize_error @@ -90,7 +90,7 @@ async def _async_validate_config_item( # noqa: C901 def _humanize(err: Exception, config: ConfigType) -> str: """Humanize vol.Invalid, stringify other exceptions.""" if isinstance(err, vol.Invalid): - return cast(str, humanize_error(config, err)) + return humanize_error(config, err) return str(err) def _log_invalid_automation( diff --git a/homeassistant/components/websocket_api/decorators.py b/homeassistant/components/websocket_api/decorators.py index b9924bc91d1fe7..2c8a6cc02f1cb9 100644 --- a/homeassistant/components/websocket_api/decorators.py +++ b/homeassistant/components/websocket_api/decorators.py @@ -145,7 +145,7 @@ def websocket_command( def decorate(func: const.WebSocketCommandHandler) -> const.WebSocketCommandHandler: """Decorate ws command function.""" - if is_dict and len(schema) == 1: # type only empty schema + if is_dict and len(schema) == 1: # type: ignore[arg-type] # type only empty schema func._ws_schema = False # type: ignore[attr-defined] # noqa: SLF001 elif is_dict: func._ws_schema = messages.BASE_COMMAND_MESSAGE_SCHEMA.extend(schema) # type: ignore[attr-defined] # noqa: SLF001 diff --git a/homeassistant/config.py b/homeassistant/config.py index ff679d4df51885..96bc94636a2b7b 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -947,7 +947,7 @@ def _log_pkg_error( def _identify_config_schema(module: ComponentProtocol) -> str | None: """Extract the schema and identify list or dict based.""" if not isinstance(module.CONFIG_SCHEMA, vol.Schema): - return None + return None # type: ignore[unreachable] schema = module.CONFIG_SCHEMA.schema diff --git a/homeassistant/data_entry_flow.py b/homeassistant/data_entry_flow.py index f632e3e4ddecf7..3ac5f85dfc866b 100644 --- a/homeassistant/data_entry_flow.py +++ b/homeassistant/data_entry_flow.py @@ -112,9 +112,7 @@ class UnknownStep(FlowError): """Unknown step specified.""" -# ignore misc is required as vol.Invalid is not typed -# mypy error: Class cannot subclass "Invalid" (has type "Any") -class InvalidData(vol.Invalid): # type: ignore[misc] +class InvalidData(vol.Invalid): """Invalid data provided.""" def __init__( @@ -386,7 +384,7 @@ async def _async_configure( ) is not None and user_input is not None: data_schema = cast(vol.Schema, data_schema) try: - user_input = data_schema(user_input) # type: ignore[operator] + user_input = data_schema(user_input) except vol.Invalid as ex: raised_errors = [ex] if isinstance(ex, vol.MultipleInvalid): diff --git a/homeassistant/helpers/data_entry_flow.py b/homeassistant/helpers/data_entry_flow.py index 2adab32195ba95..b2cad292e3d631 100644 --- a/homeassistant/helpers/data_entry_flow.py +++ b/homeassistant/helpers/data_entry_flow.py @@ -47,7 +47,7 @@ def _prepare_result_json( data = result.copy() if (schema := data["data_schema"]) is None: - data["data_schema"] = [] + data["data_schema"] = [] # type: ignore[typeddict-item] # json result type else: data["data_schema"] = voluptuous_serialize.convert( schema, custom_serializer=cv.custom_serializer diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index af165f29ae4072..c058152c2c4531 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -60,7 +60,7 @@ ulid-transform==0.9.0 urllib3>=1.26.5,<2 voluptuous-openapi==0.0.4 voluptuous-serialize==2.6.0 -voluptuous==0.13.1 +voluptuous==0.15.2 webrtc-noise-gain==1.2.3 yarl==1.9.4 zeroconf==0.132.2 diff --git a/homeassistant/util/yaml/objects.py b/homeassistant/util/yaml/objects.py index d35ba11d25ec6e..7e4019331c6f25 100644 --- a/homeassistant/util/yaml/objects.py +++ b/homeassistant/util/yaml/objects.py @@ -29,7 +29,7 @@ class NodeStrClass(str): def __voluptuous_compile__(self, schema: vol.Schema) -> Any: """Needed because vol.Schema.compile does not handle str subclasses.""" - return _compile_scalar(self) + return _compile_scalar(self) # type: ignore[no-untyped-call] class NodeDictClass(dict): diff --git a/pyproject.toml b/pyproject.toml index d09e4b13d69b2f..6322b330d241b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,7 +67,7 @@ dependencies = [ # Temporary setting an upper bound, to prevent compat issues with urllib3>=2 # https://github.com/home-assistant/core/issues/97248 "urllib3>=1.26.5,<2", - "voluptuous==0.13.1", + "voluptuous==0.15.2", "voluptuous-serialize==2.6.0", "voluptuous-openapi==0.0.4", "yarl==1.9.4", diff --git a/requirements.txt b/requirements.txt index f41fca19eccc42..a5349c4dd91e33 100644 --- a/requirements.txt +++ b/requirements.txt @@ -39,7 +39,7 @@ SQLAlchemy==2.0.31 typing-extensions>=4.12.2,<5.0 ulid-transform==0.9.0 urllib3>=1.26.5,<2 -voluptuous==0.13.1 +voluptuous==0.15.2 voluptuous-serialize==2.6.0 voluptuous-openapi==0.0.4 yarl==1.9.4