Don't import TypeVars from core modules (#68154)

This commit is contained in:
Marc Mueller 2022-03-15 09:30:55 +01:00 committed by GitHub
parent 7ab9e5cf0f
commit 376ac1bd83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -12,7 +12,7 @@ from zigpy.exceptions import ZigbeeException
from zigpy.zcl.clusters import security from zigpy.zcl.clusters import security
from zigpy.zcl.clusters.security import IasAce as AceCluster 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 .. import registries, typing as zha_typing
from ..const import ( from ..const import (
@ -23,6 +23,7 @@ from ..const import (
WARNING_DEVICE_STROBE_HIGH, WARNING_DEVICE_STROBE_HIGH,
WARNING_DEVICE_STROBE_YES, WARNING_DEVICE_STROBE_YES,
) )
from ..typing import CALLABLE_T
from .base import ChannelStatus, ZigbeeChannel from .base import ChannelStatus, ZigbeeChannel
IAS_ACE_ARM = 0x0000 # ("arm", (t.enum8, t.CharacterString, t.uint8_t), False), IAS_ACE_ARM = 0x0000 # ("arm", (t.enum8, t.CharacterString, t.uint8_t), False),

View File

@ -4,12 +4,12 @@ from __future__ import annotations
from collections.abc import Callable, Iterable from collections.abc import Callable, Iterable
import logging import logging
import re import re
from typing import Any from typing import Any, TypeVar
import voluptuous as vol import voluptuous as vol
from homeassistant.const import ATTR_ENTITY_ID, ATTR_SUPPORTED_FEATURES 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.exceptions import HomeAssistantError
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
@ -17,6 +17,7 @@ from . import config_validation as cv
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
_SlotsType = dict[str, Any] _SlotsType = dict[str, Any]
_T = TypeVar("_T")
INTENT_TURN_OFF = "HassTurnOff" INTENT_TURN_OFF = "HassTurnOff"
INTENT_TURN_ON = "HassTurnOn" INTENT_TURN_ON = "HassTurnOn"
@ -163,7 +164,7 @@ class IntentHandler:
return f"<{self.__class__.__name__} - {self.intent_type}>" 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.""" """Fuzzy matching function."""
matches = [] matches = []
pattern = ".*?".join(name) pattern = ".*?".join(name)