Align max expected entities constant between modules (#118102)

This commit is contained in:
J. Nick Koston 2024-05-27 14:06:16 -10:00 committed by GitHub
parent 722feb285b
commit 33ff84469a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 5 deletions

View file

@ -7,16 +7,15 @@ from functools import lru_cache
import re
from typing import Any
from homeassistant.const import MAX_EXPECTED_ENTITY_IDS
from homeassistant.core import split_entity_id
_MAX_EXPECTED_ENTITIES = 16384
class EntityValues:
"""Class to store entity id based values.
This class is expected to only be used infrequently
as it caches all entity ids up to _MAX_EXPECTED_ENTITIES.
as it caches all entity ids up to MAX_EXPECTED_ENTITY_IDS.
The cache includes `self` so it is important to
only use this in places where usage of `EntityValues` is immortal.
@ -41,7 +40,7 @@ class EntityValues:
self._glob = compiled
@lru_cache(maxsize=_MAX_EXPECTED_ENTITIES)
@lru_cache(maxsize=MAX_EXPECTED_ENTITY_IDS)
def get(self, entity_id: str) -> dict[str, str]:
"""Get config for an entity id."""
domain, _ = split_entity_id(entity_id)