diff --git a/homeassistant/auth/mfa_modules/notify.py b/homeassistant/auth/mfa_modules/notify.py index 464ce495050..1de6c38aecf 100644 --- a/homeassistant/auth/mfa_modules/notify.py +++ b/homeassistant/auth/mfa_modules/notify.py @@ -320,6 +320,7 @@ class NotifySetupFlow(SetupFlow): errors: dict[str, str] = {} hass = self._auth_module.hass + assert self._secret and self._count if user_input: verified = await hass.async_add_executor_job( _verify_otp, self._secret, user_input["code"], self._count @@ -334,7 +335,6 @@ class NotifySetupFlow(SetupFlow): errors["base"] = "invalid_code" # generate code every time, no retry logic - assert self._secret and self._count code = await hass.async_add_executor_job( _generate_otp, self._secret, self._count ) diff --git a/homeassistant/components/http/static.py b/homeassistant/components/http/static.py index e5e84ca141d..c4dc97727a9 100644 --- a/homeassistant/components/http/static.py +++ b/homeassistant/components/http/static.py @@ -23,7 +23,7 @@ PATH_CACHE = LRU(512) def _get_file_path( - filename: str, directory: Path, follow_symlinks: bool + filename: str | Path, directory: Path, follow_symlinks: bool ) -> Path | None: filepath = directory.joinpath(filename).resolve() if not follow_symlinks: diff --git a/homeassistant/config.py b/homeassistant/config.py index 5c870918231..91f94bbbf40 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -286,6 +286,7 @@ async def async_create_default_config(hass: HomeAssistant) -> bool: Return if creation was successful. """ + assert hass.config.config_dir return await hass.async_add_executor_job( _write_default_config, hass.config.config_dir ) diff --git a/homeassistant/helpers/event.py b/homeassistant/helpers/event.py index 85cd684fca1..d18af953ec6 100644 --- a/homeassistant/helpers/event.py +++ b/homeassistant/helpers/event.py @@ -141,7 +141,7 @@ def threaded_listener_factory( def async_track_state_change( hass: HomeAssistant, entity_ids: str | Iterable[str], - action: Callable[[str, State, State], Awaitable[None] | None], + action: Callable[[str, State | None, State], Awaitable[None] | None], from_state: None | str | Iterable[str] = None, to_state: None | str | Iterable[str] = None, ) -> CALLBACK_TYPE: @@ -197,9 +197,9 @@ def async_track_state_change( """Handle specific state changes.""" hass.async_run_hass_job( job, - event.data.get("entity_id"), + event.data["entity_id"], event.data.get("old_state"), - event.data.get("new_state"), + event.data["new_state"], ) @callback