1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Improve setup_time typing (#66509)

This commit is contained in:
Marc Mueller
2022-02-14 14:24:58 +01:00
committed by GitHub
parent dbd26c7faf
commit b2ee7cebc9
3 changed files with 15 additions and 11 deletions

View File

@@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio
from collections.abc import Awaitable, Callable, Generator, Iterable
import contextlib
from datetime import timedelta
import logging.handlers
from timeit import default_timer as timer
from types import ModuleType
@@ -436,7 +437,7 @@ def async_start_setup(
"""Keep track of when setup starts and finishes."""
setup_started = hass.data.setdefault(DATA_SETUP_STARTED, {})
started = dt_util.utcnow()
unique_components = {}
unique_components: dict[str, str] = {}
for domain in components:
unique = ensure_unique_string(domain, setup_started)
unique_components[unique] = domain
@@ -444,7 +445,7 @@ def async_start_setup(
yield
setup_time = hass.data.setdefault(DATA_SETUP_TIME, {})
setup_time: dict[str, timedelta] = hass.data.setdefault(DATA_SETUP_TIME, {})
time_taken = dt_util.utcnow() - started
for unique, domain in unique_components.items():
del setup_started[unique]