Skip to content
New issue

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

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

Already on GitHub? # to your account

Improve config vol.Invalid typing #120482

Merged
merged 1 commit into from
Jun 26, 2024
Merged
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
8 changes: 4 additions & 4 deletions homeassistant/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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:
Expand All @@ -646,7 +646,7 @@ def find_annotation_for_key(
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:
Expand Down