Skip to content

Commit

Permalink
Fix call_soon_threadsafe typing
Browse files Browse the repository at this point in the history
Result from a recent typeshed change -> better asyncio callback typing with Ts
  • Loading branch information
cdce8p committed Feb 24, 2024
1 parent f7c77e1 commit 501b27a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 501b27a

Please sign in to comment.