1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Use ReadOnlyDict for entity registry options (#93824)

* Use ReadOnlyDict for entity registry options

While reviewing #93601 it was noticed this was slow at startup
https://github.com/home-assistant/core/pull/93601#issuecomment-1568958280

This is a first pass attempt to improve the performance

* fix tests
This commit is contained in:
J. Nick Koston
2023-05-30 19:11:39 -05:00
committed by GitHub
parent 31e217a11e
commit 9f0d3bfce8
4 changed files with 19 additions and 30 deletions

View File

@@ -748,13 +748,13 @@ async def test_update_entity_options(entity_registry: er.EntityRegistry) -> None
assert new_entry_1.options == {"light": {"minimum_brightness": 20}}
# Test it's not possible to modify the options
with pytest.raises(NotImplementedError):
with pytest.raises(RuntimeError):
new_entry_1.options["blah"] = {}
with pytest.raises(NotImplementedError):
with pytest.raises(RuntimeError):
new_entry_1.options["light"] = {}
with pytest.raises(TypeError):
with pytest.raises(RuntimeError):
new_entry_1.options["light"]["blah"] = 123
with pytest.raises(TypeError):
with pytest.raises(RuntimeError):
new_entry_1.options["light"]["minimum_brightness"] = 123
entity_registry.async_update_entity_options(