From 376ac1bd8373a0544f9b04240cb7d04a59d787f8 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 15 Mar 2022 09:30:55 +0100 Subject: [PATCH] Don't import TypeVars from core modules (#68154) --- homeassistant/components/zha/core/channels/security.py | 3 ++- homeassistant/helpers/intent.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/zha/core/channels/security.py b/homeassistant/components/zha/core/channels/security.py index 5ef0ee3d9fa..8aa5c620656 100644 --- a/homeassistant/components/zha/core/channels/security.py +++ b/homeassistant/components/zha/core/channels/security.py @@ -12,7 +12,7 @@ from zigpy.exceptions import ZigbeeException from zigpy.zcl.clusters import security from zigpy.zcl.clusters.security import IasAce as AceCluster -from homeassistant.core import CALLABLE_T, callback +from homeassistant.core import callback from .. import registries, typing as zha_typing from ..const import ( @@ -23,6 +23,7 @@ from ..const import ( WARNING_DEVICE_STROBE_HIGH, WARNING_DEVICE_STROBE_YES, ) +from ..typing import CALLABLE_T from .base import ChannelStatus, ZigbeeChannel IAS_ACE_ARM = 0x0000 # ("arm", (t.enum8, t.CharacterString, t.uint8_t), False), diff --git a/homeassistant/helpers/intent.py b/homeassistant/helpers/intent.py index 44dd21d7fa3..7b0b1033016 100644 --- a/homeassistant/helpers/intent.py +++ b/homeassistant/helpers/intent.py @@ -4,12 +4,12 @@ from __future__ import annotations from collections.abc import Callable, Iterable import logging import re -from typing import Any +from typing import Any, TypeVar import voluptuous as vol from homeassistant.const import ATTR_ENTITY_ID, ATTR_SUPPORTED_FEATURES -from homeassistant.core import Context, HomeAssistant, State, T, callback +from homeassistant.core import Context, HomeAssistant, State, callback from homeassistant.exceptions import HomeAssistantError from homeassistant.loader import bind_hass @@ -17,6 +17,7 @@ from . import config_validation as cv _LOGGER = logging.getLogger(__name__) _SlotsType = dict[str, Any] +_T = TypeVar("_T") INTENT_TURN_OFF = "HassTurnOff" INTENT_TURN_ON = "HassTurnOn" @@ -163,7 +164,7 @@ class IntentHandler: return f"<{self.__class__.__name__} - {self.intent_type}>" -def _fuzzymatch(name: str, items: Iterable[T], key: Callable[[T], str]) -> T | None: +def _fuzzymatch(name: str, items: Iterable[_T], key: Callable[[_T], str]) -> _T | None: """Fuzzy matching function.""" matches = [] pattern = ".*?".join(name)