From c8fd502736f42dc3f909bf4694d267ed673d0488 Mon Sep 17 00:00:00 2001 From: gensyn <36128035+gensyn@users.noreply.github.com> Date: Sat, 9 May 2026 07:43:26 +0200 Subject: [PATCH] Refactor coordinator.py by removing workaround for asyncssh Removed unused import of sys and related error handling for fido2.client.windows. --- coordinator.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/coordinator.py b/coordinator.py index 88086d0..1aac8ee 100644 --- a/coordinator.py +++ b/coordinator.py @@ -12,28 +12,9 @@ import logging import socket -import sys from pathlib import Path from typing import Any -_LOGGER = logging.getLogger(__name__) - -# asyncssh optionally imports fido2.client.windows for Windows WebAuthn support. -# fido2's Windows-specific module (win_api) uses ctypes.HRESULT, which Python 3.14 -# removed on non-Windows platforms, causing an AttributeError that asyncssh does not -# catch (it only catches ImportError in that code path). Pre-attempt the import here -# so that on failure we can replace the broken sys.modules entry with None, which -# makes Python raise ImportError instead — and asyncssh handles that gracefully. -if sys.platform != "win32": - try: - import fido2.client.windows # noqa: F401 - except (ImportError, OSError, AttributeError) as _fido2_err: - _LOGGER.debug( - "fido2.client.windows unavailable (%s); asyncssh Windows WebAuthn support disabled", - _fido2_err, - ) - sys.modules["fido2.client.windows"] = None # type: ignore[assignment] - from asyncssh import HostKeyNotVerifiable, KeyImportError, PermissionDenied, connect, read_known_hosts from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, CONF_HOST, CONF_COMMAND, CONF_TIMEOUT @@ -54,6 +35,8 @@ CONST_DEFAULT_TIMEOUT, ) +_LOGGER = logging.getLogger(__name__) + class SshCommandCoordinator: """Single owner of all SSH I/O for the SSH Command integration.