diff --git a/homeassistant/core.py b/homeassistant/core.py index 0f038149d63..e1bd5750c16 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -513,6 +513,11 @@ class HomeAssistant: """ if target is None: raise ValueError("Don't call add_job with None") + if asyncio.iscoroutine(target): + self.loop.call_soon_threadsafe(self.async_add_job, target) + return + if TYPE_CHECKING: + target = cast(Callable[..., Any], target) self.loop.call_soon_threadsafe(self.async_add_job, target, *args) @overload diff --git a/requirements_test.txt b/requirements_test.txt index f3f0bfe5b8e..d367e81c0b2 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -11,7 +11,7 @@ astroid==3.1.0 coverage==7.4.3 freezegun==1.4.0 mock-open==1.4.0 -mypy==1.8.0 +mypy-dev==1.9.0b1 pre-commit==3.6.2 pydantic==1.10.12 pylint==3.1.0