mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Adjust type hint in core add_job (#66503)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
35b343de9e
commit
0a7b1dec7d
@ -349,7 +349,9 @@ class HomeAssistant:
|
||||
self.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
_async_create_timer(self)
|
||||
|
||||
def add_job(self, target: Callable[..., Any], *args: Any) -> None:
|
||||
def add_job(
|
||||
self, target: Callable[..., Any] | Coroutine[Any, Any, Any], *args: Any
|
||||
) -> None:
|
||||
"""Add a job to be executed by the event loop or by an executor.
|
||||
|
||||
If the job is either a coroutine or decorated with @callback, it will be
|
||||
|
@ -66,11 +66,7 @@ def discover(
|
||||
hass_config: ConfigType,
|
||||
) -> None:
|
||||
"""Fire discovery event. Can ensure a component is loaded."""
|
||||
hass.add_job(
|
||||
async_discover( # type: ignore
|
||||
hass, service, discovered, component, hass_config
|
||||
)
|
||||
)
|
||||
hass.add_job(async_discover(hass, service, discovered, component, hass_config))
|
||||
|
||||
|
||||
@bind_hass
|
||||
@ -131,9 +127,7 @@ def load_platform(
|
||||
) -> None:
|
||||
"""Load a component and platform dynamically."""
|
||||
hass.add_job(
|
||||
async_load_platform( # type: ignore
|
||||
hass, component, platform, discovered, hass_config
|
||||
)
|
||||
async_load_platform(hass, component, platform, discovered, hass_config)
|
||||
)
|
||||
|
||||
|
||||
|
@ -674,7 +674,7 @@ class Entity(ABC):
|
||||
If state is changed more than once before the ha state change task has
|
||||
been executed, the intermediate state transitions will be missed.
|
||||
"""
|
||||
self.hass.add_job(self.async_update_ha_state(force_refresh)) # type: ignore
|
||||
self.hass.add_job(self.async_update_ha_state(force_refresh))
|
||||
|
||||
@callback
|
||||
def async_schedule_update_ha_state(self, force_refresh: bool = False) -> None:
|
||||
|
@ -105,7 +105,7 @@ class EntityComponent:
|
||||
|
||||
This doesn't block the executor to protect from deadlocks.
|
||||
"""
|
||||
self.hass.add_job(self.async_setup(config)) # type: ignore
|
||||
self.hass.add_job(self.async_setup(config))
|
||||
|
||||
async def async_setup(self, config: ConfigType) -> None:
|
||||
"""Set up a full entity component.
|
||||
|
Loading…
x
Reference in New Issue
Block a user