1
mirror of https://github.com/home-assistant/core synced 2024-07-12 07:21:24 +02:00

Fix TypeAlias + TypeVar names (#76897)

This commit is contained in:
Marc Mueller 2022-08-17 03:19:55 +02:00 committed by GitHub
parent ec1b133201
commit d73754d292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -74,8 +74,8 @@ ENCRYPTED_MODEL_USES_POWER = {"JU6400", "JU641D"}
REST_EXCEPTIONS = (HttpApiError, AsyncioTimeoutError, ResponseError)
_TRemote = TypeVar("_TRemote", SamsungTVWSAsyncRemote, SamsungTVEncryptedWSAsyncRemote)
_TCommand = TypeVar("_TCommand", SamsungTVCommand, SamsungTVEncryptedCommand)
_RemoteT = TypeVar("_RemoteT", SamsungTVWSAsyncRemote, SamsungTVEncryptedWSAsyncRemote)
_CommandT = TypeVar("_CommandT", SamsungTVCommand, SamsungTVEncryptedCommand)
def mac_from_device_info(info: dict[str, Any]) -> str | None:
@ -367,7 +367,7 @@ class SamsungTVLegacyBridge(SamsungTVBridge):
LOGGER.debug("Could not establish connection")
class SamsungTVWSBaseBridge(SamsungTVBridge, Generic[_TRemote, _TCommand]):
class SamsungTVWSBaseBridge(SamsungTVBridge, Generic[_RemoteT, _CommandT]):
"""The Bridge for WebSocket TVs (v1/v2)."""
def __init__(
@ -379,7 +379,7 @@ class SamsungTVWSBaseBridge(SamsungTVBridge, Generic[_TRemote, _TCommand]):
) -> None:
"""Initialize Bridge."""
super().__init__(hass, method, host, port)
self._remote: _TRemote | None = None
self._remote: _RemoteT | None = None
self._remote_lock = asyncio.Lock()
async def async_is_on(self) -> bool:
@ -389,7 +389,7 @@ class SamsungTVWSBaseBridge(SamsungTVBridge, Generic[_TRemote, _TCommand]):
return remote.is_alive() # type: ignore[no-any-return]
return False
async def _async_send_commands(self, commands: list[_TCommand]) -> None:
async def _async_send_commands(self, commands: list[_CommandT]) -> None:
"""Send the commands using websocket protocol."""
try:
# recreate connection if connection was dead
@ -410,7 +410,7 @@ class SamsungTVWSBaseBridge(SamsungTVBridge, Generic[_TRemote, _TCommand]):
# Different reasons, e.g. hostname not resolveable
pass
async def _async_get_remote(self) -> _TRemote | None:
async def _async_get_remote(self) -> _RemoteT | None:
"""Create or return a remote control instance."""
if (remote := self._remote) and remote.is_alive():
# If we have one then try to use it
@ -422,7 +422,7 @@ class SamsungTVWSBaseBridge(SamsungTVBridge, Generic[_TRemote, _TCommand]):
return await self._async_get_remote_under_lock()
@abstractmethod
async def _async_get_remote_under_lock(self) -> _TRemote | None:
async def _async_get_remote_under_lock(self) -> _RemoteT | None:
"""Create or return a remote control instance."""
async def async_close_remote(self) -> None:

View File

@ -51,7 +51,7 @@ DEFAULT_NAME = "zamg"
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10)
VIENNA_TIME_ZONE = dt_util.get_time_zone("Europe/Vienna")
DTypeT = Union[type[int], type[float], type[str]]
_DType = Union[type[int], type[float], type[str]]
@dataclass
@ -59,7 +59,7 @@ class ZamgRequiredKeysMixin:
"""Mixin for required keys."""
col_heading: str
dtype: DTypeT
dtype: _DType
@dataclass
@ -178,7 +178,7 @@ SENSOR_TYPES: tuple[ZamgSensorEntityDescription, ...] = (
SENSOR_KEYS: list[str] = [desc.key for desc in SENSOR_TYPES]
API_FIELDS: dict[str, tuple[str, DTypeT]] = {
API_FIELDS: dict[str, tuple[str, _DType]] = {
desc.col_heading: (desc.key, desc.dtype) for desc in SENSOR_TYPES
}