Fix small type issues [core] (#75760)

This commit is contained in:
Marc Mueller 2022-07-26 16:28:22 +02:00 committed by GitHub
parent 9ad273a59f
commit af7df260a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 5 deletions

View File

@ -320,6 +320,7 @@ class NotifySetupFlow(SetupFlow):
errors: dict[str, str] = {} errors: dict[str, str] = {}
hass = self._auth_module.hass hass = self._auth_module.hass
assert self._secret and self._count
if user_input: if user_input:
verified = await hass.async_add_executor_job( verified = await hass.async_add_executor_job(
_verify_otp, self._secret, user_input["code"], self._count _verify_otp, self._secret, user_input["code"], self._count
@ -334,7 +335,6 @@ class NotifySetupFlow(SetupFlow):
errors["base"] = "invalid_code" errors["base"] = "invalid_code"
# generate code every time, no retry logic # generate code every time, no retry logic
assert self._secret and self._count
code = await hass.async_add_executor_job( code = await hass.async_add_executor_job(
_generate_otp, self._secret, self._count _generate_otp, self._secret, self._count
) )

View File

@ -23,7 +23,7 @@ PATH_CACHE = LRU(512)
def _get_file_path( def _get_file_path(
filename: str, directory: Path, follow_symlinks: bool filename: str | Path, directory: Path, follow_symlinks: bool
) -> Path | None: ) -> Path | None:
filepath = directory.joinpath(filename).resolve() filepath = directory.joinpath(filename).resolve()
if not follow_symlinks: if not follow_symlinks:

View File

@ -286,6 +286,7 @@ async def async_create_default_config(hass: HomeAssistant) -> bool:
Return if creation was successful. Return if creation was successful.
""" """
assert hass.config.config_dir
return await hass.async_add_executor_job( return await hass.async_add_executor_job(
_write_default_config, hass.config.config_dir _write_default_config, hass.config.config_dir
) )

View File

@ -141,7 +141,7 @@ def threaded_listener_factory(
def async_track_state_change( def async_track_state_change(
hass: HomeAssistant, hass: HomeAssistant,
entity_ids: str | Iterable[str], 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, from_state: None | str | Iterable[str] = None,
to_state: None | str | Iterable[str] = None, to_state: None | str | Iterable[str] = None,
) -> CALLBACK_TYPE: ) -> CALLBACK_TYPE:
@ -197,9 +197,9 @@ def async_track_state_change(
"""Handle specific state changes.""" """Handle specific state changes."""
hass.async_run_hass_job( hass.async_run_hass_job(
job, job,
event.data.get("entity_id"), event.data["entity_id"],
event.data.get("old_state"), event.data.get("old_state"),
event.data.get("new_state"), event.data["new_state"],
) )
@callback @callback