1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-23 12:29:55 +00:00

Generics and other type hint improvements (#45250)

This commit is contained in:
Ville Skyttä
2021-01-18 23:23:25 +02:00
committed by GitHub
parent 4928476abe
commit 94dbcc9d2b
7 changed files with 92 additions and 45 deletions

View File

@@ -6,18 +6,20 @@ from typing import Any, Dict, Optional, Pattern
from homeassistant.core import split_entity_id
# mypy: disallow-any-generics
class EntityValues:
"""Class to store entity id based values."""
def __init__(
self,
exact: Optional[Dict] = None,
domain: Optional[Dict] = None,
glob: Optional[Dict] = None,
exact: Optional[Dict[str, Dict[str, str]]] = None,
domain: Optional[Dict[str, Dict[str, str]]] = None,
glob: Optional[Dict[str, Dict[str, str]]] = None,
) -> None:
"""Initialize an EntityConfigDict."""
self._cache: Dict[str, Dict] = {}
self._cache: Dict[str, Dict[str, str]] = {}
self._exact = exact
self._domain = domain
@@ -30,7 +32,7 @@ class EntityValues:
self._glob = compiled
def get(self, entity_id: str) -> Dict:
def get(self, entity_id: str) -> Dict[str, str]:
"""Get config for an entity id."""
if entity_id in self._cache:
return self._cache[entity_id]