From 1cbacd13aa0d7c2a40d0d4b7e34d46cfe30efb3f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 2 Jan 2024 01:33:02 -1000 Subject: [PATCH] Use identity checks for HassJobType (#106860) --- homeassistant/core.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/homeassistant/core.py b/homeassistant/core.py index cb17bd55805..c8d01309767 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -604,13 +604,13 @@ class HomeAssistant: # if TYPE_CHECKING to avoid the overhead of constructing # the type used for the cast. For history see: # https://github.com/home-assistant/core/pull/71960 - if hassjob.job_type == HassJobType.Coroutinefunction: + if hassjob.job_type is HassJobType.Coroutinefunction: if TYPE_CHECKING: hassjob.target = cast( Callable[..., Coroutine[Any, Any, _R]], hassjob.target ) task = self.loop.create_task(hassjob.target(*args), name=hassjob.name) - elif hassjob.job_type == HassJobType.Callback: + elif hassjob.job_type is HassJobType.Callback: if TYPE_CHECKING: hassjob.target = cast(Callable[..., _R], hassjob.target) self.loop.call_soon(hassjob.target, *args) @@ -709,7 +709,7 @@ class HomeAssistant: # if TYPE_CHECKING to avoid the overhead of constructing # the type used for the cast. For history see: # https://github.com/home-assistant/core/pull/71960 - if hassjob.job_type == HassJobType.Callback: + if hassjob.job_type is HassJobType.Callback: if TYPE_CHECKING: hassjob.target = cast(Callable[..., _R], hassjob.target) hassjob.target(*args) @@ -2215,11 +2215,11 @@ class ServiceRegistry: """Execute a service.""" job = handler.job target = job.target - if job.job_type == HassJobType.Coroutinefunction: + if job.job_type is HassJobType.Coroutinefunction: if TYPE_CHECKING: target = cast(Callable[..., Coroutine[Any, Any, _R]], target) return await target(service_call) - if job.job_type == HassJobType.Callback: + if job.job_type is HassJobType.Callback: if TYPE_CHECKING: target = cast(Callable[..., _R], target) return target(service_call)