From f0be33fc6a49d02e7e5d61ea147a9fa86b9752d5 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 1 Mar 2024 13:31:28 +0100 Subject: [PATCH] Update mypy to a custom version (#111258) * Update mypy to a custom version * Fix call_soon_threadsafe typing Result from a recent typeshed change -> better asyncio callback typing with Ts --- homeassistant/core.py | 5 +++++ requirements_test.txt | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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