diff --git a/.strict-typing b/.strict-typing index 3e524e48345d32347ae66e51d0bf996d4dd5a429..c9c1ab56377e073918d80da2ab42b54f2ea1a074 100644 --- a/.strict-typing +++ b/.strict-typing @@ -412,6 +412,7 @@ homeassistant.components.todo.* homeassistant.components.tolo.* homeassistant.components.tplink.* homeassistant.components.tplink_omada.* +homeassistant.components.trace.* homeassistant.components.tractive.* homeassistant.components.tradfri.* homeassistant.components.trafikverket_camera.* diff --git a/homeassistant/components/trace/__init__.py b/homeassistant/components/trace/__init__.py index 84619b7a9830f2a532d93775dc0bff3c396355e5..43e591bc6e110572600960046881b3b474aa9211 100644 --- a/homeassistant/components/trace/__init__.py +++ b/homeassistant/components/trace/__init__.py @@ -44,7 +44,7 @@ TraceData = dict[str, LimitedSizeDict[str, BaseTrace]] @callback def _get_data(hass: HomeAssistant) -> TraceData: - return hass.data[DATA_TRACE] + return hass.data[DATA_TRACE] # type: ignore[no-any-return] async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: diff --git a/homeassistant/components/trace/models.py b/homeassistant/components/trace/models.py index 9530554449edef3a2b62486b469445c3277582ae..2fe37412dfb2a1d97c442dc8d3cae273485ce4e6 100644 --- a/homeassistant/components/trace/models.py +++ b/homeassistant/components/trace/models.py @@ -163,8 +163,8 @@ class RestoredTrace(BaseTrace): def as_extended_dict(self) -> dict[str, Any]: """Return an extended dictionary version of this RestoredTrace.""" - return self._dict + return self._dict # type: ignore[no-any-return] def as_short_dict(self) -> dict[str, Any]: """Return a brief dictionary version of this RestoredTrace.""" - return self._short_dict + return self._short_dict # type: ignore[no-any-return] diff --git a/homeassistant/components/trace/websocket_api.py b/homeassistant/components/trace/websocket_api.py index bf5ebfc1031b8a9520e0b20ca8f4584a42a36616..6a5280aacf7a31116ff32ff50c4aa40d6a64f8b5 100644 --- a/homeassistant/components/trace/websocket_api.py +++ b/homeassistant/components/trace/websocket_api.py @@ -142,8 +142,8 @@ def websocket_breakpoint_set( ) -> None: """Set breakpoint.""" key = f"{msg['domain']}.{msg['item_id']}" - node = msg["node"] - run_id = msg.get("run_id") + node: str = msg["node"] + run_id: str | None = msg.get("run_id") if ( SCRIPT_BREAKPOINT_HIT not in hass.data.get(DATA_DISPATCHER, {}) @@ -173,8 +173,8 @@ def websocket_breakpoint_clear( ) -> None: """Clear breakpoint.""" key = f"{msg['domain']}.{msg['item_id']}" - node = msg["node"] - run_id = msg.get("run_id") + node: str = msg["node"] + run_id: str | None = msg.get("run_id") result = breakpoint_clear(hass, key, run_id, node) @@ -211,7 +211,7 @@ def websocket_subscribe_breakpoint_events( """Subscribe to breakpoint events.""" @callback - def breakpoint_hit(key, run_id, node): + def breakpoint_hit(key: str, run_id: str, node: str) -> None: """Forward events to websocket.""" domain, item_id = key.split(".", 1) connection.send_message( @@ -231,7 +231,7 @@ def websocket_subscribe_breakpoint_events( ) @callback - def unsub(): + def unsub() -> None: """Unsubscribe from breakpoint events.""" remove_signal() if ( @@ -263,7 +263,7 @@ def websocket_debug_continue( ) -> None: """Resume execution of halted script or automation.""" key = f"{msg['domain']}.{msg['item_id']}" - run_id = msg["run_id"] + run_id: str = msg["run_id"] result = debug_continue(hass, key, run_id) @@ -287,7 +287,7 @@ def websocket_debug_step( ) -> None: """Single step a halted script or automation.""" key = f"{msg['domain']}.{msg['item_id']}" - run_id = msg["run_id"] + run_id: str = msg["run_id"] result = debug_step(hass, key, run_id) @@ -311,7 +311,7 @@ def websocket_debug_stop( ) -> None: """Stop a halted script or automation.""" key = f"{msg['domain']}.{msg['item_id']}" - run_id = msg["run_id"] + run_id: str = msg["run_id"] result = debug_stop(hass, key, run_id) diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index 07f10e13dbf62c674aac33d7cd68ee743d39d407..823a5c171f4d437b5c0e55175fd96621f311bfe9 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -78,7 +78,7 @@ from homeassistant.util.dt import utcnow from . import condition, config_validation as cv, service, template from .condition import ConditionCheckerType, trace_condition_function -from .dispatcher import async_dispatcher_connect, async_dispatcher_send +from .dispatcher import SignalType, async_dispatcher_connect, async_dispatcher_send from .event import async_call_later, async_track_template from .script_variables import ScriptVariables from .trace import ( @@ -142,7 +142,7 @@ _SHUTDOWN_MAX_WAIT = 60 ACTION_TRACE_NODE_MAX_LEN = 20 # Max length of a trace node for repeated actions -SCRIPT_BREAKPOINT_HIT = "script_breakpoint_hit" +SCRIPT_BREAKPOINT_HIT = SignalType[str, str, str]("script_breakpoint_hit") SCRIPT_DEBUG_CONTINUE_STOP = "script_debug_continue_stop_{}_{}" SCRIPT_DEBUG_CONTINUE_ALL = "script_debug_continue_all" @@ -1793,7 +1793,9 @@ class Script: @callback -def breakpoint_clear(hass, key, run_id, node): +def breakpoint_clear( + hass: HomeAssistant, key: str, run_id: str | None, node: str +) -> None: """Clear a breakpoint.""" run_id = run_id or RUN_ID_ANY breakpoints = hass.data[DATA_SCRIPT_BREAKPOINTS] @@ -1809,7 +1811,9 @@ def breakpoint_clear_all(hass: HomeAssistant) -> None: @callback -def breakpoint_set(hass, key, run_id, node): +def breakpoint_set( + hass: HomeAssistant, key: str, run_id: str | None, node: str +) -> None: """Set a breakpoint.""" run_id = run_id or RUN_ID_ANY breakpoints = hass.data[DATA_SCRIPT_BREAKPOINTS] @@ -1834,7 +1838,7 @@ def breakpoint_list(hass: HomeAssistant) -> list[dict[str, Any]]: @callback -def debug_continue(hass, key, run_id): +def debug_continue(hass: HomeAssistant, key: str, run_id: str) -> None: """Continue execution of a halted script.""" # Clear any wildcard breakpoint breakpoint_clear(hass, key, run_id, NODE_ANY) @@ -1844,7 +1848,7 @@ def debug_continue(hass, key, run_id): @callback -def debug_step(hass, key, run_id): +def debug_step(hass: HomeAssistant, key: str, run_id: str) -> None: """Single step a halted script.""" # Set a wildcard breakpoint breakpoint_set(hass, key, run_id, NODE_ANY) @@ -1854,7 +1858,7 @@ def debug_step(hass, key, run_id): @callback -def debug_stop(hass, key, run_id): +def debug_stop(hass: HomeAssistant, key: str, run_id: str) -> None: """Stop execution of a running or halted script.""" signal = SCRIPT_DEBUG_CONTINUE_STOP.format(key, run_id) async_dispatcher_send(hass, signal, "stop") diff --git a/mypy.ini b/mypy.ini index 5045659cabdde6f91d9c9ceed49f0b4ae5678781..42051b4ce822f3a448b86e6b58f32ca04bb3b44c 100644 --- a/mypy.ini +++ b/mypy.ini @@ -3882,6 +3882,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.trace.*] +check_untyped_defs = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +warn_return_any = true +warn_unreachable = true + [mypy-homeassistant.components.tractive.*] check_untyped_defs = true disallow_incomplete_defs = true