Adjust type hint in core add_job (#66503)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-02-14 11:13:10 +01:00 committed by GitHub
parent 35b343de9e
commit 0a7b1dec7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 11 deletions

View File

@ -349,7 +349,9 @@ class HomeAssistant:
self.bus.async_fire(EVENT_HOMEASSISTANT_STARTED) self.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
_async_create_timer(self) _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. """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 If the job is either a coroutine or decorated with @callback, it will be

View File

@ -66,11 +66,7 @@ def discover(
hass_config: ConfigType, hass_config: ConfigType,
) -> None: ) -> None:
"""Fire discovery event. Can ensure a component is loaded.""" """Fire discovery event. Can ensure a component is loaded."""
hass.add_job( hass.add_job(async_discover(hass, service, discovered, component, hass_config))
async_discover( # type: ignore
hass, service, discovered, component, hass_config
)
)
@bind_hass @bind_hass
@ -131,9 +127,7 @@ def load_platform(
) -> None: ) -> None:
"""Load a component and platform dynamically.""" """Load a component and platform dynamically."""
hass.add_job( hass.add_job(
async_load_platform( # type: ignore async_load_platform(hass, component, platform, discovered, hass_config)
hass, component, platform, discovered, hass_config
)
) )

View File

@ -674,7 +674,7 @@ class Entity(ABC):
If state is changed more than once before the ha state change task has If state is changed more than once before the ha state change task has
been executed, the intermediate state transitions will be missed. 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 @callback
def async_schedule_update_ha_state(self, force_refresh: bool = False) -> None: def async_schedule_update_ha_state(self, force_refresh: bool = False) -> None:

View File

@ -105,7 +105,7 @@ class EntityComponent:
This doesn't block the executor to protect from deadlocks. 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: async def async_setup(self, config: ConfigType) -> None:
"""Set up a full entity component. """Set up a full entity component.