mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Add a guard to handle unhashable platforms in config (#113607)
Someone might set the platform to [fitbit] instead of fitbit I have not seen anyone do this, but its good to guard against it
This commit is contained in:
parent
5dccd8204c
commit
4174d88ad7
@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Callable, Iterable, Sequence
|
||||
from collections.abc import Callable, Hashable, Iterable, Sequence
|
||||
from contextlib import suppress
|
||||
from dataclasses import dataclass
|
||||
from enum import StrEnum
|
||||
@ -1415,7 +1415,7 @@ def extract_platform_integrations(
|
||||
platform = item.get(CONF_PLATFORM)
|
||||
except AttributeError:
|
||||
continue
|
||||
if platform:
|
||||
if platform and isinstance(platform, Hashable):
|
||||
platform_integrations.setdefault(domain, set()).add(platform)
|
||||
return platform_integrations
|
||||
|
||||
|
@ -2348,6 +2348,7 @@ def test_extract_platform_integrations() -> None:
|
||||
[
|
||||
(b"zone", {"platform": "not str"}),
|
||||
("zone", {"platform": "hello"}),
|
||||
("switch", {"platform": ["un", "hash", "able"]}),
|
||||
("zonex", []),
|
||||
("zoney", ""),
|
||||
("notzone", {"platform": "nothello"}),
|
||||
@ -2363,6 +2364,7 @@ def test_extract_platform_integrations() -> None:
|
||||
assert config_util.extract_platform_integrations(config, {"zone"}) == {
|
||||
"zone": {"hello", "hello 2"}
|
||||
}
|
||||
assert config_util.extract_platform_integrations(config, {"switch"}) == {}
|
||||
assert config_util.extract_platform_integrations(config, {"zonex"}) == {}
|
||||
assert config_util.extract_platform_integrations(config, {"zoney"}) == {}
|
||||
assert config_util.extract_platform_integrations(
|
||||
|
Loading…
x
Reference in New Issue
Block a user