Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump voluptuous to 0.15.0 #120268

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/auth/login_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/auth/mfa_setup_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/automation/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/websocket_api/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/data_entry_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

# 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__(
Expand Down Expand Up @@ -180,7 +180,7 @@
"""
schema = data_schema.schema
error_path = error.path
if not error_path or (path_part := error_path[0]) not in schema:

Check failure on line 183 in homeassistant/data_entry_flow.py

View workflow job for this annotation

GitHub Actions / Check mypy

Unsupported right operand type for in ("Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] | <12 more items> | None") [operator]
raise ValueError("Could not find path in schema")

if len(error_path) > 1:
Expand Down Expand Up @@ -386,7 +386,7 @@
) 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):
Expand Down Expand Up @@ -677,7 +677,7 @@
be left untouched if there is no matching item.
"""
schema = {}
for key, val in data_schema.schema.items():

Check failure on line 680 in homeassistant/data_entry_flow.py

View workflow job for this annotation

GitHub Actions / Check mypy

Item "Schema" of "Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] | <12 more items> | None" has no attribute "items" [union-attr]

Check failure on line 680 in homeassistant/data_entry_flow.py

View workflow job for this annotation

GitHub Actions / Check mypy

Item "list[Any]" of "Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] | <12 more items> | None" has no attribute "items" [union-attr]

Check failure on line 680 in homeassistant/data_entry_flow.py

View workflow job for this annotation

GitHub Actions / Check mypy

Item "tuple[Any, ...]" of "Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] | <12 more items> | None" has no attribute "items" [union-attr]

Check failure on line 680 in homeassistant/data_entry_flow.py

View workflow job for this annotation

GitHub Actions / Check mypy

Item "frozenset[Any]" of "Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] | <12 more items> | None" has no attribute "items" [union-attr]

Check failure on line 680 in homeassistant/data_entry_flow.py

View workflow job for this annotation

GitHub Actions / Check mypy

Item "set[Any]" of "Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] | <12 more items> | None" has no attribute "items" [union-attr]

Check failure on line 680 in homeassistant/data_entry_flow.py

View workflow job for this annotation

GitHub Actions / Check mypy

Item "bool" of "Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] | <12 more items> | None" has no attribute "items" [union-attr]

Check failure on line 680 in homeassistant/data_entry_flow.py

View workflow job for this annotation

GitHub Actions / Check mypy

Item "bytes" of "Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] | <12 more items> | None" has no attribute "items" [union-attr]

Check failure on line 680 in homeassistant/data_entry_flow.py

View workflow job for this annotation

GitHub Actions / Check mypy

Item "int" of "Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] | <12 more items> | None" has no attribute "items" [union-attr]

Check failure on line 680 in homeassistant/data_entry_flow.py

View workflow job for this annotation

GitHub Actions / Check mypy

Item "str" of "Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] | <12 more items> | None" has no attribute "items" [union-attr]
if isinstance(key, vol.Marker):
# Exclude advanced field
if (
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/helpers/data_entry_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.0
webrtc-noise-gain==1.2.3
yarl==1.9.4
zeroconf==0.132.2
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/util/yaml/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"voluptuous-openapi==0.0.4",
"yarl==1.9.4",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.0
voluptuous-serialize==2.6.0
voluptuous-openapi==0.0.4
yarl==1.9.4
Loading