1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-23 12:13:49 +01:00

[core] Add some types to loader.py (#10967)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Jesse Hills
2025-10-02 02:36:17 +13:00
committed by GitHub
parent de21c61b6a
commit 1deb79a24b

View File

@@ -192,7 +192,7 @@ def install_custom_components_meta_finder():
install_meta_finder(custom_components_dir)
def _lookup_module(domain, exception):
def _lookup_module(domain: str, exception: bool) -> ComponentManifest | None:
if domain in _COMPONENT_CACHE:
return _COMPONENT_CACHE[domain]
@@ -219,16 +219,16 @@ def _lookup_module(domain, exception):
return manif
def get_component(domain, exception=False):
def get_component(domain: str, exception: bool = False) -> ComponentManifest | None:
assert "." not in domain
return _lookup_module(domain, exception)
def get_platform(domain, platform):
def get_platform(domain: str, platform: str) -> ComponentManifest | None:
full = f"{platform}.{domain}"
return _lookup_module(full, False)
_COMPONENT_CACHE = {}
_COMPONENT_CACHE: dict[str, ComponentManifest] = {}
CORE_COMPONENTS_PATH = (Path(__file__).parent / "components").resolve()
_COMPONENT_CACHE["esphome"] = ComponentManifest(esphome.core.config)