Fix invalid-else in samsungtv (#143942)

This commit is contained in:
epenet 2025-04-30 12:34:36 +02:00 committed by GitHub
parent 40217e764d
commit 73a1dbffeb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -510,6 +510,7 @@ class SamsungTVWSBridge(
async def async_try_connect(self) -> str:
"""Try to connect to the Websocket TV."""
temp_result = None
for self.port in WEBSOCKET_PORTS:
config = {
CONF_NAME: VALUE_CONF_NAME,
@ -521,7 +522,6 @@ class SamsungTVWSBridge(
CONF_TIMEOUT: TIMEOUT_REQUEST,
}
result = None
try:
LOGGER.debug("Try config: %s", config)
async with SamsungTVWSAsyncRemote(
@ -545,22 +545,19 @@ class SamsungTVWSBridge(
config,
err,
)
result = RESULT_NOT_SUPPORTED
temp_result = RESULT_NOT_SUPPORTED
except WebSocketException as err:
LOGGER.debug(
"Working but unsupported config: %s, error: %s", config, err
)
result = RESULT_NOT_SUPPORTED
temp_result = RESULT_NOT_SUPPORTED
except UnauthorizedError as err:
LOGGER.debug("Failing config: %s, %s error: %s", config, type(err), err)
return RESULT_AUTH_MISSING
except (ConnectionFailure, OSError, AsyncioTimeoutError) as err:
LOGGER.debug("Failing config: %s, %s error: %s", config, type(err), err)
else: # noqa: PLW0120
if result:
return result
return RESULT_CANNOT_CONNECT
return temp_result or RESULT_CANNOT_CONNECT
async def async_device_info(self, force: bool = False) -> dict[str, Any] | None:
"""Try to gather infos of this TV."""