From 501b27a8ef6b51d8dcc60fb28d8110d1af125772 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 24 Feb 2024 02:01:57 +0100 Subject: [PATCH] Fix call_soon_threadsafe typing Result from a recent typeshed change -> better asyncio callback typing with Ts --- homeassistant/core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/homeassistant/core.py b/homeassistant/core.py index c49777a67fb779..f7a3666e4a1936 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -508,6 +508,11 @@ def add_job( """ 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