From 6fb32db151ad5cadea8b138b9605fd96a4c3c370 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 26 Jun 2024 03:03:54 +0200 Subject: [PATCH] Improve config vol.Invalid typing (#120482) --- homeassistant/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/config.py b/homeassistant/config.py index 8e22f2051f0..ff679d4df51 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -614,7 +614,7 @@ def _get_annotation(item: Any) -> tuple[str, int | str] | None: return (getattr(item, "__config_file__"), getattr(item, "__line__", "?")) -def _get_by_path(data: dict | list, items: list[str | int]) -> Any: +def _get_by_path(data: dict | list, items: list[Hashable]) -> Any: """Access a nested object in root by item sequence. Returns None in case of error. @@ -626,7 +626,7 @@ def _get_by_path(data: dict | list, items: list[str | int]) -> Any: def find_annotation( - config: dict | list, path: list[str | int] + config: dict | list, path: list[Hashable] ) -> tuple[str, int | str] | None: """Find file/line annotation for a node in config pointed to by path. @@ -636,7 +636,7 @@ def find_annotation( """ def find_annotation_for_key( - item: dict, path: list[str | int], tail: str | int + item: dict, path: list[Hashable], tail: Hashable ) -> tuple[str, int | str] | None: for key in item: if key == tail: @@ -646,7 +646,7 @@ def find_annotation( return None def find_annotation_rec( - config: dict | list, path: list[str | int], tail: str | int | None + config: dict | list, path: list[Hashable], tail: Hashable | None ) -> tuple[str, int | str] | None: item = _get_by_path(config, path) if isinstance(item, dict) and tail is not None: