Add Self typing (2) [mypy 1.0] (#87599)

This commit is contained in:
Marc Mueller 2023-02-07 05:23:52 +01:00 committed by GitHub
parent 37bb1e8948
commit a5d376069a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 41 additions and 62 deletions

View file

@ -5,7 +5,9 @@ import asyncio
from collections.abc import Callable
import functools
import logging
from typing import TYPE_CHECKING, Any, TypeVar
from typing import TYPE_CHECKING, Any
from typing_extensions import Self
from homeassistant.const import ATTR_NAME
from homeassistant.core import CALLBACK_TYPE, Event, callback
@ -35,9 +37,6 @@ if TYPE_CHECKING:
from .core.channels.base import ZigbeeChannel
from .core.device import ZHADevice
_ZhaEntitySelfT = TypeVar("_ZhaEntitySelfT", bound="ZhaEntity")
_ZhaGroupEntitySelfT = TypeVar("_ZhaGroupEntitySelfT", bound="ZhaGroupEntity")
_LOGGER = logging.getLogger(__name__)
ENTITY_SUFFIX = "entity_suffix"
@ -181,12 +180,12 @@ class ZhaEntity(BaseZhaEntity, RestoreEntity):
@classmethod
def create_entity(
cls: type[_ZhaEntitySelfT],
cls,
unique_id: str,
zha_device: ZHADevice,
channels: list[ZigbeeChannel],
**kwargs: Any,
) -> _ZhaEntitySelfT | None:
) -> Self | None:
"""Entity Factory.
Return entity if it is a supported configuration, otherwise return None
@ -279,13 +278,13 @@ class ZhaGroupEntity(BaseZhaEntity):
@classmethod
def create_entity(
cls: type[_ZhaGroupEntitySelfT],
cls,
entity_ids: list[str],
unique_id: str,
group_id: int,
zha_device: ZHADevice,
**kwargs: Any,
) -> _ZhaGroupEntitySelfT | None:
) -> Self | None:
"""Group Entity Factory.
Return entity if it is a supported configuration, otherwise return None