Skip to content

Commit

Permalink
Process review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck committed Dec 11, 2023
1 parent d7f2329 commit 31b8815
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions homeassistant/helpers/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,25 @@ async def _async_get_component_icons(
class _IconsCache:
"""Cache for flattened icons."""

__slots__ = ("_hass", "loaded", "cache")
__slots__ = ("_hass", "_loaded", "_cache")

def __init__(self, hass: HomeAssistant) -> None:
"""Initialize the cache."""
self._hass = hass
self.loaded: set[str] = set()
self.cache: dict[str, dict[str, Any]] = {}
self._loaded: set[str] = set()
self._cache: dict[str, dict[str, Any]] = {}

async def async_fetch(
self,
category: str,
components: set[str],
) -> list[dict[str, dict[str, Any]]]:
"""Load resources into the cache."""
if components_to_load := components - self.loaded:
if components_to_load := components - self._loaded:
await self._async_load(components_to_load)

return [
self.cache.get(component, {}).get(category, {}) for component in components
self._cache.get(component, {}).get(category, {}) for component in components
]

async def _async_load(self, components: set[str]) -> None:
Expand All @@ -125,7 +125,7 @@ async def _async_load(self, components: set[str]) -> None:

self._build_category_cache(components, icons)

self.loaded.update(components)
self._loaded.update(components)

@callback
def _build_category_cache(
Expand All @@ -142,7 +142,7 @@ def _build_category_cache(
for category in categories:
new_resources = build_resources(icons, components, category)
for component, resource in new_resources.items():
category_cache: dict[str, Any] = self.cache.setdefault(
category_cache: dict[str, Any] = self._cache.setdefault(
component, {}
).setdefault(category, {})

Expand Down

0 comments on commit 31b8815

Please sign in to comment.