From c920d7d5e0efe079568ace19f26ea058b90b9ba1 Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Thu, 14 Apr 2022 23:04:32 +0200 Subject: [PATCH] Improve typing of deCONZ diagnostics (#69491) * Improve typing of deCONZ diagnostics homeassistant/components/deconz/diagnostics.py:28: error: Item "None" of "Optional[WSClient]" has no attribute "state" [union-attr] homeassistant/components/deconz/diagnostics.py:40: error: Unpacking a string is disallowed [misc] homeassistant/components/deconz/diagnostics.py:40: error: Cannot determine type of "k" [has-type] homeassistant/components/deconz/diagnostics.py:40: error: Cannot determine type of "v" [has-type] homeassistant/components/deconz/diagnostics.py:42: error: Unpacking a string is disallowed [misc] homeassistant/components/deconz/diagnostics.py:42: error: Cannot determine type of "k" [has-type] homeassistant/components/deconz/diagnostics.py:42: error: Cannot determine type of "v" [has-type] * Fix review comments * These mypy ignores arent useful until py.typed is introduced with the library which I will do once I resolve as much as possible in the integration --- homeassistant/components/deconz/diagnostics.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/deconz/diagnostics.py b/homeassistant/components/deconz/diagnostics.py index d8fdfeae2bd..11854421512 100644 --- a/homeassistant/components/deconz/diagnostics.py +++ b/homeassistant/components/deconz/diagnostics.py @@ -25,7 +25,9 @@ async def async_get_config_entry_diagnostics( diag["deconz_config"] = async_redact_data( gateway.api.config.raw, REDACT_DECONZ_CONFIG ) - diag["websocket_state"] = gateway.api.websocket.state + diag["websocket_state"] = ( + gateway.api.websocket.state if gateway.api.websocket else "Unknown" + ) diag["deconz_ids"] = gateway.deconz_ids diag["entities"] = gateway.entities diag["events"] = {