Fix TypeAlias + TypeVar names (#76897)
parent
ec1b133201
commit
d73754d292
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue