Fix TypeAlias + TypeVar names (#76897)
parent
ec1b133201
commit
d73754d292
|
@ -74,8 +74,8 @@ ENCRYPTED_MODEL_USES_POWER = {"JU6400", "JU641D"}
|
||||||
|
|
||||||
REST_EXCEPTIONS = (HttpApiError, AsyncioTimeoutError, ResponseError)
|
REST_EXCEPTIONS = (HttpApiError, AsyncioTimeoutError, ResponseError)
|
||||||
|
|
||||||
_TRemote = TypeVar("_TRemote", SamsungTVWSAsyncRemote, SamsungTVEncryptedWSAsyncRemote)
|
_RemoteT = TypeVar("_RemoteT", SamsungTVWSAsyncRemote, SamsungTVEncryptedWSAsyncRemote)
|
||||||
_TCommand = TypeVar("_TCommand", SamsungTVCommand, SamsungTVEncryptedCommand)
|
_CommandT = TypeVar("_CommandT", SamsungTVCommand, SamsungTVEncryptedCommand)
|
||||||
|
|
||||||
|
|
||||||
def mac_from_device_info(info: dict[str, Any]) -> str | None:
|
def mac_from_device_info(info: dict[str, Any]) -> str | None:
|
||||||
|
@ -367,7 +367,7 @@ class SamsungTVLegacyBridge(SamsungTVBridge):
|
||||||
LOGGER.debug("Could not establish connection")
|
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)."""
|
"""The Bridge for WebSocket TVs (v1/v2)."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -379,7 +379,7 @@ class SamsungTVWSBaseBridge(SamsungTVBridge, Generic[_TRemote, _TCommand]):
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize Bridge."""
|
"""Initialize Bridge."""
|
||||||
super().__init__(hass, method, host, port)
|
super().__init__(hass, method, host, port)
|
||||||
self._remote: _TRemote | None = None
|
self._remote: _RemoteT | None = None
|
||||||
self._remote_lock = asyncio.Lock()
|
self._remote_lock = asyncio.Lock()
|
||||||
|
|
||||||
async def async_is_on(self) -> bool:
|
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 remote.is_alive() # type: ignore[no-any-return]
|
||||||
return False
|
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."""
|
"""Send the commands using websocket protocol."""
|
||||||
try:
|
try:
|
||||||
# recreate connection if connection was dead
|
# recreate connection if connection was dead
|
||||||
|
@ -410,7 +410,7 @@ class SamsungTVWSBaseBridge(SamsungTVBridge, Generic[_TRemote, _TCommand]):
|
||||||
# Different reasons, e.g. hostname not resolveable
|
# Different reasons, e.g. hostname not resolveable
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def _async_get_remote(self) -> _TRemote | None:
|
async def _async_get_remote(self) -> _RemoteT | None:
|
||||||
"""Create or return a remote control instance."""
|
"""Create or return a remote control instance."""
|
||||||
if (remote := self._remote) and remote.is_alive():
|
if (remote := self._remote) and remote.is_alive():
|
||||||
# If we have one then try to use it
|
# 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()
|
return await self._async_get_remote_under_lock()
|
||||||
|
|
||||||
@abstractmethod
|
@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."""
|
"""Create or return a remote control instance."""
|
||||||
|
|
||||||
async def async_close_remote(self) -> None:
|
async def async_close_remote(self) -> None:
|
||||||
|
|
|
@ -51,7 +51,7 @@ DEFAULT_NAME = "zamg"
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10)
|
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10)
|
||||||
VIENNA_TIME_ZONE = dt_util.get_time_zone("Europe/Vienna")
|
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
|
@dataclass
|
||||||
|
@ -59,7 +59,7 @@ class ZamgRequiredKeysMixin:
|
||||||
"""Mixin for required keys."""
|
"""Mixin for required keys."""
|
||||||
|
|
||||||
col_heading: str
|
col_heading: str
|
||||||
dtype: DTypeT
|
dtype: _DType
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -178,7 +178,7 @@ SENSOR_TYPES: tuple[ZamgSensorEntityDescription, ...] = (
|
||||||
|
|
||||||
SENSOR_KEYS: list[str] = [desc.key for desc in SENSOR_TYPES]
|
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
|
desc.col_heading: (desc.key, desc.dtype) for desc in SENSOR_TYPES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue