Add support for after_dependencies (#23148)
* Add support for after_dependencies * Remove assert false" * Fix types
This commit is contained in:
parent
7b1cbeaf80
commit
10e8f4f70a
9 changed files with 296 additions and 60 deletions
|
@ -21,6 +21,8 @@ from typing import (
|
|||
TypeVar,
|
||||
List,
|
||||
Dict,
|
||||
Union,
|
||||
cast,
|
||||
)
|
||||
|
||||
# Typing imports that create a circular dependency
|
||||
|
@ -116,6 +118,8 @@ class Integration:
|
|||
self.name = manifest['name'] # type: str
|
||||
self.domain = manifest['domain'] # type: str
|
||||
self.dependencies = manifest['dependencies'] # type: List[str]
|
||||
self.after_dependencies = manifest.get(
|
||||
'after_dependencies') # type: Optional[List[str]]
|
||||
self.requirements = manifest['requirements'] # type: List[str]
|
||||
_LOGGER.info("Loaded %s from %s", self.domain, pkg_path)
|
||||
|
||||
|
@ -150,7 +154,8 @@ async def async_get_integration(hass: 'HomeAssistant', domain: str)\
|
|||
raise IntegrationNotFound(domain)
|
||||
cache = hass.data[DATA_INTEGRATIONS] = {}
|
||||
|
||||
int_or_evt = cache.get(domain, _UNDEF) # type: Optional[Integration]
|
||||
int_or_evt = cache.get(
|
||||
domain, _UNDEF) # type: Optional[Union[Integration, asyncio.Event]]
|
||||
|
||||
if isinstance(int_or_evt, asyncio.Event):
|
||||
await int_or_evt.wait()
|
||||
|
@ -161,7 +166,7 @@ async def async_get_integration(hass: 'HomeAssistant', domain: str)\
|
|||
elif int_or_evt is None:
|
||||
raise IntegrationNotFound(domain)
|
||||
else:
|
||||
return int_or_evt
|
||||
return cast(Integration, int_or_evt)
|
||||
|
||||
event = cache[domain] = asyncio.Event()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue