From d73754d292136d7daf952fec731583a6e83833eb Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 17 Aug 2022 03:19:55 +0200 Subject: [PATCH] Fix TypeAlias + TypeVar names (#76897) --- homeassistant/components/samsungtv/bridge.py | 14 +++++++------- homeassistant/components/zamg/sensor.py | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/samsungtv/bridge.py b/homeassistant/components/samsungtv/bridge.py index fe0b102647a3..f1618bfba14b 100644 --- a/homeassistant/components/samsungtv/bridge.py +++ b/homeassistant/components/samsungtv/bridge.py @@ -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: diff --git a/homeassistant/components/zamg/sensor.py b/homeassistant/components/zamg/sensor.py index 8452841520b7..e8d5f745cceb 100644 --- a/homeassistant/components/zamg/sensor.py +++ b/homeassistant/components/zamg/sensor.py @@ -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 }