From b8d649d927ad8e99bdc75a16fadc6f28366ff9df Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 23 Jun 2024 16:27:13 -0500 Subject: [PATCH 1/6] Bump voluptuous to 0.15.0 changelog: https://github.com/alecthomas/voluptuous/compare/0.13.1...0.15.0 --- homeassistant/package_constraints.txt | 2 +- pyproject.toml | 2 +- requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index a21d89705e8150..a329a96ac68924 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -59,7 +59,7 @@ typing-extensions>=4.12.2,<5.0 ulid-transform==0.9.0 urllib3>=1.26.5,<2 voluptuous-serialize==2.6.0 -voluptuous==0.13.1 +voluptuous==0.15.0 webrtc-noise-gain==1.2.3 yarl==1.9.4 zeroconf==0.132.2 diff --git a/pyproject.toml b/pyproject.toml index 9f83edd7f3e940..d731d648d206ea 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.0", "voluptuous-serialize==2.6.0", "yarl==1.9.4", ] diff --git a/requirements.txt b/requirements.txt index 4c5e349d8b66fa..1d92edc40c07cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -39,6 +39,6 @@ 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.0 voluptuous-serialize==2.6.0 yarl==1.9.4 From 0a04f328845d86c8bf46db0d244f8194e24ae491 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 25 Jun 2024 13:06:40 +0200 Subject: [PATCH 2/6] ignore no-untyped-call --- homeassistant/util/yaml/objects.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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): From 78218a04786d4153751b5d09066d62c721da05da Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 26 Jun 2024 02:19:15 +0200 Subject: [PATCH 3/6] Remove redundant cast --- homeassistant/components/automation/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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( From dfbb7bf382cacf16251a31edd5b4a475099d0ba8 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 26 Jun 2024 02:50:16 +0200 Subject: [PATCH 4/6] Update type ignore comments --- homeassistant/components/websocket_api/decorators.py | 2 +- homeassistant/config.py | 2 +- homeassistant/data_entry_flow.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 8e22f2051f0891..6739bc07684a24 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 155e64d259e4ce..5249c07f604330 100644 --- a/homeassistant/data_entry_flow.py +++ b/homeassistant/data_entry_flow.py @@ -114,7 +114,7 @@ class UnknownStep(FlowError): # 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__( From e06a4608b859cd939dca63748b861472b92f5377 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 26 Jun 2024 02:29:57 +0200 Subject: [PATCH 5/6] Remove another type ignore comment --- homeassistant/data_entry_flow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/data_entry_flow.py b/homeassistant/data_entry_flow.py index 491ef24466dd51..c11c44d0402353 100644 --- a/homeassistant/data_entry_flow.py +++ b/homeassistant/data_entry_flow.py @@ -386,7 +386,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): From 57fa5bb873ec434eb7c8797e26c6fa9110cd815c Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:13:05 +0200 Subject: [PATCH 6/6] Add type ignores for json result type --- homeassistant/components/auth/login_flow.py | 2 +- homeassistant/components/auth/mfa_setup_flow.py | 2 +- homeassistant/helpers/data_entry_flow.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/auth/login_flow.py b/homeassistant/components/auth/login_flow.py index 5bad0dbb9998f4..96ed0a0dd295c2 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..b0213e57d2c22f 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/helpers/data_entry_flow.py b/homeassistant/helpers/data_entry_flow.py index 2adab32195ba95..b33ebbf2a94a6a 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