diff --git a/homeassistant/util/read_only_dict.py b/homeassistant/util/read_only_dict.py index 3e4710cf220b..0d12f00fab75 100644 --- a/homeassistant/util/read_only_dict.py +++ b/homeassistant/util/read_only_dict.py @@ -20,6 +20,7 @@ class ReadOnlyDict[_KT, _VT](dict[_KT, _VT]): clear = _readonly update = _readonly setdefault = _readonly + __ior__ = _readonly def __copy__(self) -> dict[_KT, _VT]: """Create a shallow copy.""" diff --git a/tests/util/test_read_only_dict.py b/tests/util/test_read_only_dict.py index 68e22a66f5ec..00b4fb4d5a05 100644 --- a/tests/util/test_read_only_dict.py +++ b/tests/util/test_read_only_dict.py @@ -33,6 +33,9 @@ def test_read_only_dict() -> None: with pytest.raises(RuntimeError): data.setdefault("yo", "yo") + with pytest.raises(RuntimeError): + data |= {"yo": "yo"} + assert isinstance(data, dict) assert dict(data) == {"hello": "world"} assert json.dumps(data) == json.dumps({"hello": "world"})