From 0293315b23cf15e148bc45e8fc99f8773879e5d0 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 20 May 2024 10:55:44 +0200 Subject: [PATCH] Use PEP 695 for covariant class annotations (#117780) --- homeassistant/core.py | 5 +---- homeassistant/helpers/debounce.py | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/homeassistant/core.py b/homeassistant/core.py index 5a370a1d91b..640e34cdedd 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -38,7 +38,6 @@ from typing import ( Final, Generic, NotRequired, - ParamSpec, Self, TypedDict, cast, @@ -131,8 +130,6 @@ CLOSE_STAGE_SHUTDOWN_TIMEOUT = 30 _R = TypeVar("_R") -_R_co = TypeVar("_R_co", covariant=True) -_P = ParamSpec("_P") # Internal; not helpers.typing.UNDEFINED due to circular dependency _UNDEF: dict[Any, Any] = {} _SENTINEL = object() @@ -305,7 +302,7 @@ class HassJobType(enum.Enum): Executor = 3 -class HassJob(Generic[_P, _R_co]): +class HassJob[**_P, _R_co]: """Represent a job to be run later. We check the callable type in advance diff --git a/homeassistant/helpers/debounce.py b/homeassistant/helpers/debounce.py index 18ee9a56225..83555b56dcb 100644 --- a/homeassistant/helpers/debounce.py +++ b/homeassistant/helpers/debounce.py @@ -5,14 +5,11 @@ from __future__ import annotations import asyncio from collections.abc import Callable from logging import Logger -from typing import Generic, TypeVar from homeassistant.core import HassJob, HomeAssistant, callback -_R_co = TypeVar("_R_co", covariant=True) - -class Debouncer(Generic[_R_co]): +class Debouncer[_R_co]: """Class to rate limit calls to a specific command.""" def __init__(